1 Introduction

An operating system is a program that manages a computers’ hardware. We can view an operating system as a resource allocator or a control program that manages the execution of user programs to prevent errors and improper use of computer. It is especially concerned with the operation and control of I/O devices.

A computer system can be divided roughly into 4 parts: the hardware, the operating system, the application programs, and the users.

But we are more focused on operating system. So let’s talk about that ^_^

2 Defining Operating Systems

Operating system is the one program running at all times on the computer - usually called the kernel, that act as an interface between the hardware and the user.

Along with the kernel, there are 2 other types of programs: system programs and application programs.

  • System programs ~> These programs are associated with the operating system but are not necessarily part of the kernel.
  • Application programs ~> All the programs not associated with the operation of the system.

3 Computer System Operation

A modern general-purpose computer system consists of one or more CPUs and a number of devices controllers connected through a common bus that provides access to shared memory.

The CPU and the device controllers can execute in parallel competing for memory cycles. To ensure orderly access to the shared memory, a memory controller synchronizes access to the memory.

3.1 Boot up process

Let’s see how a computer boots up!!!

3.1.1 Initial program / Bootstrap program

It is stored within the computer hardware in read-only memory (ROM) or electrically erasable programmable read-only memory (EEPROM), known by the general term firmware.

It initializes all aspects of the system, from CPU registers to device controllers to memory contents. The bootstrap program must know how to load the operation system and how to start executing that system. To accomplish this goal, the bootstrap program must locate the the operating-system kernel and load it into memory.

3.1.2 System processes / System daemons

Once the kernel is loaded and executing in the memory, it can start providing services to the system and its users. Some services are provided outside of the kernel, by the system programs that are loaded into memory at boot time to become system processes or system daemons that run the entire time the kernel is running.

On UNIX, the first system process is “init” and it starts many other daemons. Once this phase is complete, the system is fully booted and the system waits for some event to occur.

3.1.3 Interrupt

The occurrence of an event is usually signaled by an interrupt from either the hardware or the software. Hardware may trigger an interrupt at any time by sending a signal to the CPU, through the system bus. Software may trigger an interrupt by executing a special operation called a system call (also called a monitor call).

When the CPU is interrupted, it stops what it is doing and immediately transfers execution to a fixed location. The fixed location usually contains the starting address where the service routine for the interrupt is located. The interrupt service routine executes; on completion, the CPU resumes the interrupt computation.

Each computer design has its own interrupt mechanism, but several functions are common. The interrupt must transfer control to the appropriate interrupt service routine. Since only a predefined number of interrupt is possible, a table of pointers to interrupt routines can be used instead to provide the necessary speed. The interrupt routine is called indirectly through the table, with no intermediate routine needed.

Generally, the table of pointers is stored in low memory (the first hundred or so locations). These locations hold the addresses of the interrupt service routines for various devices.

This array or interrupt vector, of addresses is then indexed by a unique device number, given with the interrupt request, to provide the address of the interrupt service routine for the interrupting device.

4 Storage Structure

The CPU can load instructions only from memory, so any programs to run must be stored there. General-purpose computers run most of their programs from re writable memory, called main memory (also called random-access memory, or RAM). Main memory commonly is implemented in a semiconductor technology called dynamic random-access memory (DRAM).

ROM can not be changed, only static programs, such as the bootstrap program are stored there.

All forms of memory provide an array of bytes. Each byte has its own address. Interaction is achieved through a sequence of load or store instructions to specific memory addresses.

  • load ~> The load instruction moves a byte (smallest addressable unit of a CPU) or word (register size or amount of data that can be transferred between CPU and RAM) from main memory to an internal register within the CPU.

  • store ~> The store instruction moves the content of a register to main memory.

Main memory is a volatile storage that loses its contents when power is turned off and it’s too small to store all needed programs. So we need another storage media as an extension of main memory, that is secondary memory.

5 I/O Structure

Storage belongs to I/O devices within a computer. The main theme of operating system is dedicated to manage I/ O. A general purpose computer system consists of CPUs and multiple device controllers that are connected through a common bus. Each device controller is in charge of a specific type of device. Depending on the controller, more than one device may be attached. For instance, 7 or more devices can be attached to the small computer-systems interface (SCSI) controller.

A device controller maintains some local buffer storage and a set of special-purpose registers. The device controller is responsible for moving the data between the peripheral devices that it controls and it local buffer storage.

Typically, operating system have a device driver for each device controller. This device driver understands the device controller and provides the rest of the operating system with a uniform interface to the device.

5.1 I/O Operation Flow

  1. The device driver loads the appropriate registers within the device controller.
  2. The device controller examines the contents of these registers to determine what action to take (like ‘read a character from the keyboard’, ‘display a string’, etc.).
  3. The controller starts the transfer of data from the device to its local buffer.
  4. When the transfer of data is complete, the device controller informs the device driver via an interrupt that it has finished its operation.
  5. The device driver then returns control to the operating system.

This form of interrupt-driven I/O is fine for moving small amounts of data but can produce high overhead when used for bulk data movement such as disk I/O. To solve this problem, direct memory access (DMA) is used. After setting up buffers, pointers and counters for the I/O device, the device controller transfers an entire block of data directly to or from its own buffer storage to memory, with no intervention by the CPU. Only one interrupt is generated per block, to tell device driver that the operation has completed, rather than the one interrupt per byte generated for low-speed devices. So while the device controller is performing these operations, the CPU is available to accomplish other work o_0

5.2 DMA Principle

Direct memory access (DMA) is a technique for transferring data between main memory and requesting I/O device, and vice versa, independent of the processor. The hardware entity which perform the address generation and reading and writing operations is called a DMA Controller (DMAC).

5.2.1 Methodology

During data transfer operations, DMAC sends one control signal to the processor, known as the bus request (BR) signal. In response to BR, the processor completes its current jobs and sends a signal called the bus grant (BG). Once the BG is received, the DMAC takes hold of the CPU bus and initiates the signal required for the data transfer operation. DMA works in 2 modes: * Flow-through ~> In this mode, the data is transferred between the memory and I/O devices through DMAC. * Fly-by ~> In this mode, the transfer is made when the DMAC writes the address and control signals onto the bus and gives access to the device for transfer. This will transfer data between the I/O ports and memory address, but not between more than one I/O port and memory location.

Before the DMAC transfer is configured by the processor, the I/O address, read/write memory address, data size and transfer modes are written in the DMAC register.

5.3 I/O Buffering Techniques

I/O device buffering allows asynchronous data transfer between the I/O device and main memory. Without a buffer, the operating must directly access the device when it needs and consequently the running process must be suspended during I/O operations. To support I/O buffering, the operating system provides the following techniques.

  • Single Buffer
  • Double Buffer
  • Circular Buffer

6 Computer-System Architecture

A computer system can be organized in a number of different ways, which we can categorize roughly according to the number of general-purpose processors used.

6.1 Single-Processor Systems

In this system, we use one main CPU for executing general-purpose instruction set, including instructions from user processes. Almost all single-processor systems have other special-purpose processors as well.

These special-purpose processors are device-specific processors, such as disk, keyboard, graphics controllers, etc. For example, PCs contain a microprocessor in the keyboard to convert the keystrokes into codes to be sent to the CPU.

The operating system cannot communicate with these special-purpose microprocessors; they do their jobs autonomously.

These special-purpose microprocessors are common and does not turn a single-processor system into a multiprocessor.

6.2 Multiprocessor Systems

Multiprocessor systems (also known as parallel systems or multicore systems) have 2 or more processors in close communication, sharing the computer bus and sometimes the clock, memory and peripheral devices.

6.2.1 Advantages

  1. Increased throughput ~> The speed-up ratio with \(N\) processors is not \(N\), however; rather, it is less than \(N\).
  2. Cost reduction ~> A multiprocessor system can cost less than equivalent multiple single-processor systems.
  3. Increased reliability ~> If functions can be distributed properly among several processors, then the failure of one processor will not halt the system, only slow it down. For example, if we have 10 processors and 1 fails, then each of the remaining 9 processors can pick up a share of the work of the failed processors. Thus, the entire system runs only 10% slower, rather than failing altogether.

6.2.2 Some Important Terminologies

  • Graceful degradation ~> The ability to continue providing service proportional to the level of surviving hardware is called graceful degradation.

  • Fault tolerant ~> Some system go beyond graceful degradation, as they can suffer a failure of any single component and still continue operation.

6.2.3 Types of multiprocessor systems

Generally, there are 2 types of multiprocessor systems that are used today.

  1. Asymmetric ~> In this system, each processor is assigned a specific task. A master processor controls the system; the other processors either look to the master for instruction or have predefined tasks. Basically, it is a master-slave relationship.

  2. Symmetric ~> The most commonly used system where each processor performs all tasks within the operating system. Symmetric multiprocessing (SMP) means that all processors are peers.

Each processor has its own set of registers, as well as a private - or local cache. However, all processors share a physical memory. An example of SMP is AIX, a commercial version of UNIX designed by IBM.

The difference between symmetric and asymmetric multiprocessing may result from either hardware or software.

SunOS version 4 ~> provides ‘Asymmetric multiprocessing’ ^_^

SunOS version 5 (Solaris) ~> Symmetic on the same hardware O_o

6.2.4 Multicore

Multicore CPUs are kind of multiprocessor systems, where multiple chips are replaced with multiple computing cores on a single chip. They are more efficient than multiple chips with single cores because on-chip communication is faster than between-chip communication. In addition, one chip with multiple cores uses significantly less power than multiple single-core chips.

7 Questions

  1. What do you mean by ‘System programs’ and ‘Application programs’? State some differences.

  2. What do you mean by ‘Firmware’?

  3. Briefly describe ‘System daemons’ with an example.

  4. Why ‘Interrupt’ is important?

  5. What do you mean by ‘load’ and ‘store’ instructions with respect to memory?

  6. Is it possible to reside data in main memory permanently? Why?

  7. Briefly describe ‘DMA principle’ with a schematic diagram.

  8. What do you mean by ‘I/O buffering’?

  9. What do you mean by ‘Buffer space’?

  10. What do you mean by a ‘Parallel system’?

  11. What do you mean by ‘Graceful degradation’ and ‘Fault tolerant’?

  12. Briefly describe ‘Symmetric multiprocessor systems’?

  13. ‘AIX’ is an asymmetric multiprocessor system. [T/F]