Summary: OS Concepts
• Processes • layers = abstraction – Resources, Deadlocks • policies and – Pipes mechanisms • Memory Management • user versus supervisor (kernel) mode • Input/Output – different spaces • Files – different levels of • Security executions and privileges • The Shell – system calls (kernel) • Concept Recycling application code library code
25
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)
26
1 Steps in Making a System Call
There are 11 steps in making the system call
read (fd, buffer, nbytes) 27
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 */ } }
28
2 System Calls (2)
• Processes have three segments: text, data, stack 29
Some System Calls For Process Management
30
3 Some System Calls For File Management
how: O_RDONLY, O_WRONLY, O_RDWR, O_CREAT
31
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
32
4 Some System Calls For Directory Management
33
System Calls (3)
(a) Two directories before linking /usr/jim/memo to ast's directory
(b) The same directories after linking
34
5 System Calls (4)
(a) File system before the mount (b) File system after the mount
35
Some System Calls For Miscellaneous Tasks
chmod 741 means -rwxr--x
kill -9 pid means kill process given by pid
36
6 System Calls (5)
Some Win32 API calls 37
Operating System Structure (1)
Simple structuring model for a monolithic system
38
7 Monolithic Structure
OS = collection of procedures ~ rather than modules (no information hiding) Still, structure in methodology: parameters put on stack before TRAP, for example. Three “layers” 1. Main program that invokes -- dispatches -- the requested service procedure 2. Set of service procedures, to execute system calls 3. Set of utility procedures, factoring common needs of service procedures
39
Operating System Structure (2)
Structure of the THE operating system
40
8 Layered Structure in THE 5. System Operator Process 4. 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 management 0. handle interrupts, switch processes • multiprogramming, above it seq processes
41
Operating System Structure (3)
Structure of VM/370 with CMS
42
9 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
43
Operating System Structure (4)
The client-server model
44
10 Operating System Structure (5)
The client-server model in a distributed system
45
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 machine resources (e.g., disk portions) – saves one mapping layer (e.g., disk addresses) – again separates multiprogramming / niceties
46
11 OS Structure
• Monolithic Systems • Layered Systems • Virtual Machines • Exo- and Micro-kernels – Client-Server Model
mechanisms versus policies
47
Metric Units
The metric prefixes
48
12 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
49
13