Está en la página 1de 39

OPERATING SYSTEMS

THEORY
LECTURE NOTES Chapter 1 OPERATING SYSTEMS OVERVIEW

TEXT BOOK

Operating Systems Theory


by Dr G O Ofori-Dwumfuo Adwinsah Publications, 2007

Other Literature
Any good operating systems book Internet Etc.

OPERATING SYSTEM OVERVIEW


Computer systems provide for gathering

data, performing computations, storing information, communicating with other computer systems, and generating output reports. Some of those are implemented in hardware, others in software. An operating system is the software that manages hardware resources, provides services for accessing those resources, such as creation of files, directories, processes, etc.

Without OS, Computers are just machines


Application Packages

Operating System

BIOS Software

A typical computer system (Fig 1.1):


The hardware does all the actual work and includes the

memory, the central processing unit (CPU), and the input and output (I/O) devices. The OS provides a set of services to programs. The user interacts with the operating system indirectly, through the programs. Systems programs are a set of utility programs supplied with an operating system to provide basic services for users. Eg. window manager for a graphical user interface, a command interpreter, and programs to rename, copy or delete files. Application programs provide the computer with the functionality the users require. Eg. tax preparation software, a financial planner, a word processor, spreadsheet.

CPU Organization
The CPU is the heart and brain of a computer system. It contains a number of special-purpose registers, an

arithmetic logic unit (ALU), and the control unit / logic necessary to decode and execute instructions Connected to the CPU by way of a communication bus are the memory and the I/O devices. The operation of the CPU is controlled by the instructions the CPU fetches from memory. The I/O devices, in turn, are commanded by the CPU.

CPU operations
The operation of a CPU can be

described in terms of a simple loop Each time through the loop one instruction is executed. This basic process by which instructions are executed never varies. It is called the Fetch-and-execute operation

Fetch and execute operations


An instruction is fetched from the memory location specified

by program counter. (All instructions are fetched from main memory.) The instruction is placed in a special register called the instruction register. The program counter is incremented so it points to the next instruction to be executed. The instruction is decoded to determine what action is to be performed. The action is specified by the instructions opcode (operation code) bits. Depending on the operation to be performed, the value of one or more operands is fetched from memory. The operation specified in the op-code is performed (see below). If required, a value is stored back into main memory.

Op-code operations

Movement: Move a value from one location to another (registers or memory locations). Computation: Send one or more operand values to the ALU and have a computation performed. Conditional Branch: If the branch condition is true, reset the program counter to point to the branch address. Procedure Call: Save the current value of the program counter. Then reset the program counter to point to the beginning of a procedure. At the end of the procedure, a branch instruction specifying the saved program counter will allow the program to return to the current point of execution. (The saved program counter may be stored in a register, in memory, or on the stack.) Input/Output: Transfer information concerning an input or output operation between the CPU and the I/O device.

Traps and Interrupts


These are events that disrupt the

normal sequence of instructions executed by the CPU A trap is an abnormal condition detected by the CPU that indicates an error; e.g.
dividing by zero, trying to access a memory location that does not exist or for which the program does not have access, executing an instruction with an undefined opcode, or trying to access a nonexistent I/O device.

Traps and Interrupts


An interrupt is a signal sent to the CPU

by an external device, typically an I/O device; to stop its current activities and attend to the interrupting devices needs, eg, to perform a read operation. (A CPU will, however, check interrupts only after it has completed the processing of one instruction and before it fetches another.)

Traps and Interrupts.


The CPU responds to traps and interrupts by

saving the current value of the program counter and resetting the program counter to a new address. The CPU then returns to executing at the point the trap or interrupt occurred, after it has handled the trap or interrupt. Information saved when a trap or interrupt occurs is stored in a special register (program status word, PSW register).

Traps and Interrupts..


One difference between trap & interrupts:

traps are said to be synchronous and interrupts are asynchronous. Given the same machine state and input data, a trap will occur at the same point of execution each time the program runs. The occurrence of an interrupt, however, depends on the relative timing between the interrupting device and the CPU.

Multimode Execution
To provide an OS with privileges not granted to

application programs, the hardware must support multiple modes of execution. Two modes of execution are usually supported: supervisor (or kernel) mode and user mode. A system can enter kernel mode from user mode in one of three ways. Supervisor call or a system call (A special instruction call - similar to a procedure call except that it sets the systems state to kernel mode. Traps Interrupts

Objectives of Operating Systems


To hide details of hardware by creating

abstraction

An abstraction is software that hides the lower level details and provides a set of higher-level functions

To allocate resources to processes Provide a pleasant and effective user

interface

Operating System Structure


The OS provides applications with a virtual machine. The OS supervisor calls expand the instruction set

provided by the raw hardware by supporting processes, file systems, etc. In addition, the OS manages the underlying hardware resources. Applications cannot access I/O devices or execute privileged instructions directly. The OS performs these tasks on their behalf. In doing so, the OS attempts to efficiently utilize the resources available to it and protect the integrity of the applications that must share those resources.

Operating System Structure.


The tasks performed by an operating system

can be divided into four major areas. Process Management Memory Management File System Management Device Management

Process Management
A process is an executing program. Associated with a process are its code, its

data, a set of resources allocated to it, and one or more flows of execution through its code. The OS provides supervisor calls for managing processes and must manage the allocation of resources to processes. If multiple processes can exist simultaneously, the OS must provide each process with an appropriate virtual environment in which to run

Process Management
Five major activities of an operating system in regard to process management are: Creation and deletion of user and system processes. Suspension and resumption of processes. A mechanism for process synchronization. A mechanism for process communication. A mechanism for deadlock handling.

Memory Management
At a minimum, memory must be shared

by an application program and the OS. On more sophisticated systems, memory can be shared by a number of processes. The OS must manage the allocation of memory to processes and control the hardware that determines which memory locations a process may access.

Memory Management
The major activities of an operating system in regard to memory-management are: Keep track of which part of memory are currently being used and by whom. Decide which processes are loaded into memory when memory space becomes available. Allocate and de-allocate memory space as needed.

File System Management


Computers process information. That

information must be transmitted, processed, and stored. A file system object is an abstract entity for storing or transmitting a collection of information. The file system is an organized collection of file system objects. The OS must provide primitives to manipulate those objects

File System Management


The five main major activities of an operating system in regard to file management are: The creation and deletion of files. The creation and deletion of directories. The support of primitives for manipulating files and directories. The mapping of files onto secondary storage. The back-up of files on stable storage media.

Device Management
A computer communicates information

through its input and output devices. Processes access those devices through the OS supervisor calls provided for that purpose. The OS attempts to manage those devices in a manner that allows them to be efficiently shared among the processes requiring them

Operating System Services


The following services are provided by OS to the convenience of the users: Program Execution I/O Operations File System Manipulation Inter-process communication Error Detection

Operating System Types


Batch systems Multiprogrammed batch systems Time-shared systems Network operating systems Real-time operating systems Distributed operating systems

Batch systems
Earlier, computer input, both programs and data,

was prepared on input media; paper tape or punch cards Users would hand these in to an operator and return later to pick up the outputs. The operator would assemble similar jobs into batches and run the batches through the computer. Each job had total control of the machine until it terminated. A batch OS manages a machine run in this manner. It provides virtually no functionality since there are no complications of sharing resources with multiple processes.

Multiprogrammed batch systems


On multiprogrammed batch systems,

jobs are read into a job pool stored on a disk. When one job is unable to execute because it is waiting for an I/O operation to complete, another job may be allowed to run. This sharing of computer resources by concurrently executing processes greatly increases operating system complexity.

Time-shared systems
Time-shared OS allow for interaction between user

and process. In batch systems, all data is supplied at the time the program is input. This may be fine for a program that takes payroll information and prints weekly pay cheques. But for programs that must interact with the user, the OS must allow programs to respond to user inputs in a reasonable amount of time. The OS must not only share resources among the various processes, but it must create the illusion that processes are running simultaneously. It does this by shifting execution rapidly among all the active processes.

Network operating systems


Increasingly, computers exist not as

stand-alone entities but as part of a network of computers. Network communications involve complex protocols For the reliability of the network, support for those protocols is built into network operating systems.

Real-time operating systems


A real-time OS is designed for execution of

tasks within specific time constraints. Normally, users want the computer systems to execute their programs as soon as possible, but no exact timing is required. In real-time systems, the correctness of a processing task is dependent on the time at which the processing occurred. Eg, a real-time system sensing loss of coolant to a nuclear reactor may be required to initiate a backup system within a fraction of a second.

Real-time operating systems.


In a real-time environment, the OS must

guarantee that the task can be executed within a specified time constraint. Use of real-time systems is most limited to dedicated applications such as industrial control systems, weapon systems and computer-controlled products.

Real-time operating systems.


Desirable features in a time-shared system,

(resource sharing and management of I/O devices by the operating system) are detriments in a real-time system. Minimization of delays in the completion of tasks discourages resource sharing and encourages low-level access to hardware. For this reason, the design of generalpurpose OS is much different from the design of real-time systems.

Distributed operating systems


With a network OS, the resources on each

machine on the network are managed by that machines OS. OS support facilitates communications among the machines. With a distributed operating system, the OS on all the machines work together to manage the collective network resources. A single collective distributed OS manages the network resources provided by each network computer or node.

The Booting Process


When power is first supplied to a computer system, a

program in read-only memory (ROM) executes. After performing some diagnostic checks, a stage-0 boot program is executed. The program checks for the presence of one or more boot devices, eg, floppy disk, a CD-ROM or hard disk. Once found, the stage-0 program reads the first sector (called boot sector) from the boot device into main memory. This boot sector should contain a stage-1 boot program. There is however, no guarantee. If the boot sector has never been initialized, undefined values will be copied into memory. Before transferring control to the next stage in the boot process, the current boot program will check

The Booting Process..


On some systems, the stage-1 boot program then

reads in the OS. On others, a series of bootstrap programs must be copied into memory and executed. In either case, the OS eventually gets copied into memory and the final boot program branches to the OSs initialization entry point. On a hard disk PC, the boot sector also contains a partition table which contains the starting and ending location of partitions. One partition is defined as active.

The Booting Process..


At the end of the boot process, the OS has been

loaded into memory and the boot program has branched to the OS. The machine is now executing in kernel mode. Data structures not set when the operating system was loaded, system registers and devices are all initialized as needed. Once the OS is ready to service processes, it creates any processes that provide OS services. Once the system is switched into user mode, the OS has completed its boot responsibilities and the system is running.

The Booting Process over ..


The operating system is now

running and the computer system is now ready for use.

También podría gustarte