Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
O PERATING S YSTEMS
To understand the operating system is to understand the working of the entire computer system , because it is the operating system that manages each and every piece of hardware and software.
In this course we will explore what operating systems are, how they work, what they do And why?
OUTLINE
Computer System
Software (programs)
Hardware (physical machine and electronic components)
Operating System
Controls every file, device, section of main memory and nanosecond of processing time Controls who can use the system Controls how system is used
SPRING 2011 - 102
OS is a resource allocator
Manages all resources Decides between conflicting requests for efficient and fair resource use
OS is a control program
Controls execution of programs to prevent errors and improper use of the computer
SPRING 2011 - 102
Memory Manager (management programs) Processor Manager Device Manager File Manager
10
11
12
Each manager:
Manager tasks
Allocate the resource (when appropriate) De-allocate the resource (when appropriate) Resources: CPU time, memory, files, I/O
SPRING 2011 - 102
13
14
Responsibilities include:
Preserving space in main memory occupied by operating system Checking validity and legality of memory space request Setting up memory tracking table
15
P ROCESSOR M ANAGEMENT
16
D EVICE M ANAGEMENT
Responsibilities include:
17
F ILE M ANAGEMENT
Responsibilities include:
Allocating resource
18
19
C OMPUTER S TARTUP
20
Operating system Controls and coordinates use of hardware among various applications and users Application programs define the ways in which the system resources are used to solve the computing problems of the users
Word processors, compilers, web browsers, database systems, video games People, machines, other computers
SPRING 2011 - 102
Users
21
memory
Data/Instruction storage
All peripheral devices in system Printers, disk drives, CD/DVD drives, flash memory, and keyboards
22
Memory
Main memory only large storage media that the CPU can access directly.
Secondary storage extension of main memory that provides large nonvolatile storage capacity.
Magnetic disks rigid metal or glass platters covered with magnetic recording material
Disk surface is logically divided into tracks, which are subdivided into sectors.
23
DEVICE
There is the hardware unit which is connected to the machine, and there is the logical device which is a name given by the OS to a legal entry point for talking to a hardware-device.
When a user writes to a logical device, the OS invokes a device driver which performs the physical operations of controlling the hardware.
For example, when writing to a disk, the OS must control the movement of the read-write heads. When writing to a printer, the OS places the information in a queue and services the request when the printer becomes free. Some common logical devices are: the system disks, the keyboard, the screen, the printer and the audio device.
Disks and tapes are often called secondary memory or S 2011 - 102 secondary storage
PRING
24
25
I NTERRUPTS
Interrupt are central to operating systems, as they provide an efficient way for the operating system to interact with and react to its environment The occurrence of an event is usually signaled from either the hardware or the software. Interrupts are hardware signals which are sent to the CPU by the devices it is connected to. These signals literally interrupt the CPU from what it is doing and demand that it spend a few clock cycles servicing a request
Software may trigger an interrupt by executing a special operation called a system call.
SPRING 2011 - 102
26
I NTERRUPTS
,
Interrupts may come from the keyboard because a user pressed a key. Then the CPU must stop what it is doing and read the keyboard, place the key value into a buffer for later For example reading, and return to what it was doing.
For example
Disk devices generate interrupts when they have finished an I/O task
Resume
27
Trap
A trap is usually initiated by the CPU hardware. When ever the trap condition occurs (on arithmetic overflow, for example) OR A process can generate a trap, for example, by dividing a number by zero.
Signal
A signal is a limited form of inter-process communication. A user or a process may generate a signal (an interrupt to a process). When a signal is sent to a process, the operating system interrupts the process's normal flow of execution.
SPRING 2011 - 102
28
29
Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly.
Provide hardware support to differentiate between at least two modes of operations.
User mode execution done on behalf of a user. Monitor mode (also kernel mode or system mode) execution done on behalf of operating system.
30
Mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1). When an interrupt or fault occurs hardware switches to monitor mode.
Some instructions
in kernel mode
System call changes mode to kernel, return from call resets
it to user
Interrupt/fault
user
SPRING 2011 - 102
31
In this mode software has a complete access to all the hardware and can execute any instruction the machine is capable of executing
The rest of software runs in the user mode in which only a subset of machine instruction is available
32
User Mode
System Call
Signal
Interrupt
User Mode
Trap
33
34
NOT INCLUDED
35
When trap occurred the CPU stops what it's doing, saves the context, jumps to the appropriate trap routine, completes it, restores the context, and continues execution.
36
Mode
S 1 trap 2
Branch Table
Trusted Code
User
Supervisor
SPRING 2011 - 102
37
Interrupt transfers control to the interrupt service routine, generally, through the interrupt vector, which contains addresses of all the interrupt service routines.
Interrupt architecture must save the address of the instruction after the interrupted instruction and the CPU state so that execution of the interrupted process may continue after the interrupt has been
38
39
40
Personal computers computer system dedicated to a single user. Interactive User convenience and responsiveness. Can adopt technology developed for larger operating systemsmulti-process, multi-user May run several different types of operating systems (Windows, MacOS, UNIX, Linux)
41
42
M ULTIPROGRAMMING
43
Machine Pi
OS Resource Sharing
Pi Memory Pk Memory
44
M ULTIPROGRAMMING
A single user cannot keep CPU and I/O devices busy at all times. Multiprogramming offers a more efficient approach to increase system performance.
Several jobs are kept in main memory at the same time and the CPU is multiplexed among
45
H OW M ULTIPROGRAMMING W ORKS
Process 4
Space-multiplexed Memory
SPRING 2011 - 102
46
M ULTIPROGRAMMING
47
48
T IME S HARING
Time-sharing is the sharing of a computing resource among many users by means of multiprogramming
Time sharing, in which each user has an online terminal.
In Timesharing System, each user is given a time slice/quantum. The user program/process executes for a short time before it either finishes or needs to perform I/O. the resources are then taken away from the user and given to some one else.
49
T IMESHARING S YSTEMS
Abstract Machines Result
Command
Physical Machine
Result
Command
Result
Command
SPRING 2011 - 102