1
25
Summary: OS Concepts
• Processes– Resources, Deadlocks
– Pipes
• Memory Management
• Input/Output
• Files
• Security
• The Shell
• Concept Recycling
• layers = abstraction• policies and
mechanisms• user versus supervisor
(kernel) mode– different spaces– different levels of
executions andprivileges
– system calls (kernel)application codelibrary code
26
System Calls
Interface that OS provides, programs use
• set of system calls, specific to each OS
• used to transfer control of (single) CPU– program (process) invokes => context switch
– program suspended while syscall executed
– system call wrapped in library function; e.g., count = read (fd, buffer, nbytes)
2
27
Steps in Making a System Call
There are 11 steps in making the system call read (fd, buffer, nbytes)
28
System Calls (1)• A stripped down shell:
while (TRUE) { /* repeat forever */ type_prompt( ); /* display prompt */ read_command (command, parameters) /* input from
terminal */
if (fork() != 0) { /* fork off child process */ /* Parent code */ waitpid( -1, &status, 0);/* wait for child to exit */} else { /* Child code */ execve (command, parameters, 0);/* execute command */ }}
3
29
System Calls (2)
• Processes have three segments: text, data, stack
30
Some System Calls For Process Management
4
31
Some System Calls For File Management
how: O_RDONLY, O_WRONLY, O_RDWR, O_CREAT
32
Files and inodes
• every file denoted by unique i-number
• i-number is index into table of i-nodes
• directory: file containing a set of pairs:– (i-number, ASCII name)
• to link is to create a new entry with the i-number of existing file
5
33
Some System Calls For Directory Management
34
System Calls (3)
(a) Two directories before linking/usr/jim/memo to ast's directory
(b) The same directories after linking
6
35
System Calls (4)
(a) File system before the mount
(b) File system after the mount
36
Some System Calls For Miscellaneous Tasks
chmod 741 means -rwxr--x
kill -9 pid means kill process given by pid
7
37
System Calls (5)
Some Win32 API calls
38
Operating System Structure (1)
Simple structuring model for a monolithic system
8
39
Monolithic Structure
OS = collection of procedures ~ rather than modules(no information hiding)
Still, structure in methodology: parameters put onstack before TRAP, for example. Three “layers”
1. Main program that invokes -- dispatches -- therequested service procedure
2. Set of service procedures, to execute systemcalls
3. Set of utility procedures, factoring commonneeds of service procedures
40
Operating System Structure (2)
Structure of the THE operating system
9
41
Layered Structure in THE5. System Operator Process4. User processes
• I/O, console, memory, etc., taken care 0-3
3. I/O management - abstracts devices• devices, buffers, streams
2. comm. operator - console• above it, each proc has its own console
1. main memory & swap management0. handle interrupts, switch processes
• multiprogramming, above it seq processes
42
Operating System Structure (3)
Structure of VM/370 with CMS
10
43
Virtual Machine VM/370
• Virtual Machine Monitor on bare HW– offers exact copies of the underlying HW– does not add any niceties!
• On top of VM, can have several copies of– batch system– single-user, interactive system CMS
• separates– multiprogramming– extended machine
44
Operating System Structure (4)
The client-server model
11
45
Operating System Structure (5)
The client-server model in a distributed system
46
Micro-, Exo-Kernels, C-S
Insight: OS services done as user processes– user client process requests a server process
– kernel just supports interprocess comm.
Exokernels - similar to VM, but split machineresources (e.g., disk portions)– saves one mapping layer (e.g., disk addresses)
– again separates multiprogramming / niceties
12
47
OS Structure
• Monolithic Systems
• Layered Systems
• Virtual Machines
• Exo- and Micro-kernels– Client-Server Model
mechanisms versus policies
48
Metric Units
The metric prefixes
13
49
Other Units• Time between slipping on a peel and
smacking the pavement = 1 bananosecond• Half a large intestine = 1 semicolon• Time it takes to sail 220 yards at 1 nautical
mile per hour = Knot furlong• 1 millionth of a fish = 1 microfiche• 1000 aches = 1 megahertz• Basic unit of laryngitis = 1 hoarsepower• 1 million-million microphones = 1 megaphone• 1 million bicycles = 2 megacycles• 2.4 statute miles of intravenous tubing at Yale
University Hospital:1 I.V. League