Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems...
Transcript of Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems...
![Page 1: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/1.jpg)
Networks and Operating Systems Chapter 11:
Introduction to Operating Systems (252-0062-00)
Donald Kossmann & Torsten Hoefler
Frühjahrssemester 2012
© Systems Group | Department of Computer Science | ETH Zürich
![Page 2: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/2.jpg)
Last time
• Virtual circuit switching
• Packet switching
• Multiprotocol switching
• Address Resolution Protocol
• Spanning tree algorithm
• Virtual LANs
![Page 3: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/3.jpg)
Today: We start on Operating Systems!
• Introduction: Why?
• Roles of the OS
• Referee
• Illusionist
• Glue
• Structure of an OS
3
![Page 4: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/4.jpg)
Goals
• Demystify operating systems themselves
– What is an OS? What does it do?
– What is its structure?
– How do the OS and applications relate to each other?
– What services does the OS provide?
• Quintessential “systems” problem
– Non-idealizable / non-reducible
– Scaling, emergent properties
– Concurrency and asynchrony
![Page 6: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/6.jpg)
Also worth a look
• Jerome H. Saltzer and M. Frans Kaashoek: “Principles of Computer System Design”
• Focus on principles, with illustrative examples
![Page 7: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/7.jpg)
Also worth a look
• Andrew S. Tanebaum: “Modern Operating Systems”
• Must be at least 3rd Edition!
• Very broad – lots of references to recent (2006) research.
![Page 8: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/8.jpg)
Introduction to Operating Systems
![Page 9: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/9.jpg)
Why learn about Operating Systems?
• One of the most complex topics in Computer Science! – Very few simplifying assumptions
– Dealing with the real world
– Intersection of many areas
• Mainstream OSes are large: – Windows 7 ~ 50 million lines of code
– Linux rapidly catching up in complexity
• Most other software systems are a subset – Games, browsers, databases, servers, cloud, etc.
![Page 10: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/10.jpg)
Why learn about Operating Systems?
• One of the most complex topics in Computer Science! – Very few simplifying assumptions
– Dealing with the real world
– Intersection of many areas
• Mainstream OSes are large: – Windows 7 ~ 50 million lines of code
– Linux rapidly catching up in complexity (~15 million LOC)
• Most other software systems are a subset – Games, browsers, databases, servers, cloud, etc.
![Page 11: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/11.jpg)
Why learn about Operating Systems?
• One of the most complex topics in Computer Science! – Very few simplifying assumptions
– Dealing with the real world
– Intersection of many areas
• Mainstream OSes are large: – Windows 7 ~ 50 million lines of code
– Linux rapidly catching up in complexity (~15 million LOC)
• Most other software systems are a subset – Games, browsers, databases, servers, cloud, etc.
![Page 12: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/12.jpg)
There are lots of operating systems concepts…
• Systems calls
• Concurrency and asynchrony
• Processes and threads
• Security, authorization, protection
• Memory, virtual memory, and paging
• Files and file systems, data management
• I/O: Devices, Interrupts, DMA
• Network interfaces and protocol stacks
![Page 13: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/13.jpg)
There are lots of operating systems…
![Page 14: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/14.jpg)
Goals: what makes a good OS?
![Page 15: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/15.jpg)
Goals: what makes a good OS?
• Reliability: does it keep working?
– And availability
![Page 16: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/16.jpg)
Goals: what makes a good OS?
• Reliability: does it keep working?
– And availability
• Security: can it be compromised?
– And isolation: is it fair?
![Page 17: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/17.jpg)
Goals: what makes a good OS?
• Reliability: does it keep working?
– And availability
• Security: can it be compromised?
– And isolation: is it fair?
• Portability: how easily can it be retargeted?
![Page 18: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/18.jpg)
Goals: what makes a good OS?
• Reliability: does it keep working?
– And availability
• Security: can it be compromised?
– And isolation: is it fair?
• Portability: how easily can it be retargeted?
• Performance: how fast/cheap/hungry is it?
![Page 19: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/19.jpg)
Goals: what makes a good OS?
• Reliability: does it keep working?
– And availability
• Security: can it be compromised?
– And isolation: is it fair?
• Portability: how easily can it be retargeted?
• Performance: how fast/cheap/hungry is it?
• Adoption: will people use it?
![Page 20: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/20.jpg)
Operating Systems
Operating System
Applications
Hardware
![Page 21: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/21.jpg)
Operating Systems
Operating System
Applications
Hardware
Operating Systems (rest of this course!)
![Page 22: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/22.jpg)
Operating Systems
Operating System
Applications
Hardware
Parallel Programming
Operating Systems (rest of this course!)
![Page 23: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/23.jpg)
Operating Systems
Operating System
Applications
Hardware
Computer Architecture and Systems Programming
Parallel Programming
Operating Systems (rest of this course!)
![Page 24: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/24.jpg)
Operating System Roles
![Page 25: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/25.jpg)
OS roles
Referee Illusionist
Glue
![Page 26: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/26.jpg)
The Referee:
Operating System
Hardware
System calls
Resource Manager
Application Application Application
![Page 27: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/27.jpg)
The OS as Referee
• Sharing: – Multiplex hardware among applications
• CPU, memory, devices
– Applications shouldn’t need to be aware of each other
• Protection: – Ensure one application can’t r/w another’s data
• In memory, on disk, over network
– Ensure one application can’t use another’s resources • CPU, storage space, bandwidth, …
• Communication: – Protected applications must still communicate
![Page 28: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/28.jpg)
The OS as Referee
• Sharing: – Multiplex hardware among applications
• CPU, memory, devices
– Applications shouldn’t need to be aware of each other
• Protection: – Ensure one application can’t r/w another’s data
• In memory, on disk, over network
– Ensure one application can’t use another’s resources • CPU, storage space, bandwidth, …
• Communication: – Protected applications must still communicate
![Page 29: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/29.jpg)
The OS as Referee
• Sharing: – Multiplex hardware among applications
• CPU, memory, devices
– Applications shouldn’t need to be aware of each other
• Protection: – Ensure one application can’t r/w another’s data
• In memory, on disk, over network
– Ensure one application can’t use another’s resources • CPU, storage space, bandwidth, …
• Communication: – Protected applications must still communicate
![Page 30: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/30.jpg)
Resource management goals
• Fairness:
– No starvation, every application makes progress
• Efficiency:
– Best use of complete machine resources
– Minimize e.g. power consumption
• Predictability:
– Guarantee real-time performance
![Page 31: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/31.jpg)
Resource management goals
• Fairness:
– No starvation, every application makes progress
• Efficiency:
– Best use of complete machine resources
– Minimize e.g. power consumption
• Predictability:
– Guarantee real-time performance
All in mutual contradiction
![Page 32: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/32.jpg)
Example: Threads
• Threads are virtual CPUs
– Physical resource: CPUs
– Virtual resource: Threads
– Mechanism: pre-emption, timeslicing, context switching, scheduling
• More on this later in the course…
![Page 33: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/33.jpg)
The Illusionist
Virtualization:
• OS creates illusion of a “real” resource
– Processor, storage, network, links, …
• Virtual resource looks a bit like a physical resource
• However, is frequently quite different…
– Simpler, larger, better, …
![Page 34: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/34.jpg)
How?
1. Multiplexing
– Divide resources up among clients
2. Emulation
– Create the illusion of a resource using software
3. Aggregation
– Join multiple resources together to create a new one
![Page 35: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/35.jpg)
Why?
1. Sharing – Enable multiple clients of a single resource
2. Sandboxing – Prevent a client from accessing other resources
3. Decoupling – Avoid tying a client to a particular instance of a
resource
4. Abstraction – Make a resource easier to use
![Page 36: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/36.jpg)
Example: Virtual Memory
• Easier memory to manage
– Physical resource: RAM
– Virtual resource: Virtual Memory
– Method: Multiplexing
– Mechanism: virtual address translation
![Page 37: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/37.jpg)
Example: Paged virtual memory
• More memory than you really have
– Physical resource: RAM and disk
– Virtual resource: paged virtual memory
– Method: multiplexing and emulation
– Mechanism: virtual memory + paging to/from disk
• Much more on this later in the course…
![Page 38: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/38.jpg)
Example: virtual machines
• Quite popular topic commercially right now: – Xen, VMware, HyperV, kvm, etc.
• Many uses: – Run one OS on another
– Consolidate servers
– Migrate running machines around datacenter
– Run hundreds of “honeypot” machines
– Deterministic replay of whole machines
– Etc.
![Page 39: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/39.jpg)
Example: Files (or database!)
• Virtual resource: persistant memory
• Physical resource: disk
• Method: multiplexing, emulation
• Mechanism: block allocation, metadata
• Again, more later…
![Page 40: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/40.jpg)
Example: Windows (not the Microsoft OS)
• Physical resource: Frame buffer and/or GPU
• Method: Multiplexing and emulation
• Mechanism: Windows as separate bitmaps/textures
![Page 41: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/41.jpg)
Example: virtual circuits
• Physical resource: network link
• Virtualization method: multiplexing
• Mechanism: VC identifiers, VC switching
1
2 3
4
VCI=346 VCI=1044
VCI=1044 VCI=56
Virtual circuits
Real circuits
![Page 42: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/42.jpg)
Example: VLANs
42
• Methods: multiplexing
• Mechanisms: port assignment, tags
A
E G H
I
J
K S2 S1
B C D
F
M
N
N
S2 S1
![Page 43: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/43.jpg)
Glue: the OS as Abstract Machine
Operating System
Applications
Hardware
Virtual machine interface
Physical machine interface
![Page 44: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/44.jpg)
The OS as Glue
• Provides high-level abstractions
– Easier to program to
– Shared functionality for all applications
– Ties together disparate functions and services
• Extends hardware with added functionality
– Direct programming of hardware unnecessary
• Hides details of hardware
– Applications decoupled from particular devices
![Page 45: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/45.jpg)
Services provided by an OS
• Program execution – Load program, execute on 1 or more processors
• Access to I/O devices – Disk, network, keyboard, screen,…
• Protection and access control – For files, connections, etc.
• Error detection and reporting – Trap handling, etc.
• Accounting and auditing – Statistics, billing, forensics, etc.
![Page 46: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/46.jpg)
Operating System Structure
![Page 47: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/47.jpg)
General OS structure
Kernel
Privileged mode
User mode
CPU Device Device
Application
System Library
Application
System Library
Server process (daemon)
System Library
System calls
CPU
![Page 48: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/48.jpg)
Privileged Mode and User Mode
• As we saw in Computer Architecture, most CPUs have a “privileged mode”:
– ia32 protection rings
– VAX kernel mode
– Etc.
• Most Operating Systems use this for protection
– In particular, protecting the OS from applications!
![Page 49: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/49.jpg)
General OS structure
Kernel
Privileged mode
User mode
Application
System Library
Application
System Library
Server process (daemon)
System Library
System calls
CPU Device Device CPU
![Page 50: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/50.jpg)
Kernel
• That part of the OS which runs in privileged mode
– Large part of Unix and Windows (except libraries)
– Small part of L4, Barrelfish, etc. (microkernels)
– Does not exist in some embedded systems
• Also known as:
– Nucleus, nub, supervisor, …
![Page 51: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/51.jpg)
The kernel is a program!
• Kernel is just a (special) computer program.
• Typically an event-driven server.
• Responds to multiple entry points:
– System calls
– Hardware interrupts
– Program traps
• May also include internal threads.
![Page 52: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/52.jpg)
General OS structure
Kernel
Privileged mode
User mode
Application
System Library
Application
System Library
Server process (daemon)
System Library
System calls
CPU Device Device CPU
![Page 53: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/53.jpg)
System Libraries
• Convenience functions
– strcmp(), etc.
– Common functionality
• System call wrappers
– Create and execute system calls from high-level languages
– See ‘man syscalls’ on Linux
![Page 54: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/54.jpg)
General OS structure
Kernel
Privileged mode
User mode
Application
System Library
Application
System Library
Server process (daemon)
System Library
System calls
CPU Device Device CPU
![Page 55: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/55.jpg)
Daemons
• Processes which are part of the OS
– Microkernels: most of the OS
– Linux: increasingly large quantity
• Advantages:
– Modularity, fault tolerance
– Easier to schedule…
![Page 56: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/56.jpg)
Entering and exiting the kernel
![Page 57: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/57.jpg)
When is the kernel entered?
• Startup
• Exception: caused by user program
• Interrupt: caused by “something else”
• System calls
![Page 58: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/58.jpg)
Recall: System Calls
• RPC to the kernel
• Kernel is a series of syscall event handlers
• Mechanism is hardware-dependent
System calls
Privileged mode
User mode
![Page 59: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/59.jpg)
Recall: System Calls
• RPC to the kernel
• Kernel is a series of syscall event handlers
• Mechanism is hardware-dependent
System calls
Privileged mode
User mode
User process runs
![Page 60: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/60.jpg)
Recall: System Calls
• RPC to the kernel
• Kernel is a series of syscall event handlers
• Mechanism is hardware-dependent
System calls
Privileged mode
User mode
User process runs Execute syscall
![Page 61: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/61.jpg)
Recall: System Calls
• RPC to the kernel
• Kernel is a series of syscall event handlers
• Mechanism is hardware-dependent
System calls
Privileged mode
User mode
User process runs Execute syscall
![Page 62: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/62.jpg)
Recall: System Calls
• RPC to the kernel
• Kernel is a series of syscall event handlers
• Mechanism is hardware-dependent
System calls
Privileged mode
User mode
User process runs
Execute kernel code
Execute syscall
![Page 63: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/63.jpg)
Recall: System Calls
• RPC to the kernel
• Kernel is a series of syscall event handlers
• Mechanism is hardware-dependent
System calls
Privileged mode
User mode
User process runs Process resumes
Execute kernel code
Execute syscall
![Page 64: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/64.jpg)
System call arguments
Syscalls are the way a program requests services from the OS kernel.
Implementation varies:
• Passed in processor registers
• Stored in memory (address in register)
• Pushed on the stack
• System library (libc) wraps as a C function
• Kernel code wraps handler as C call
![Page 65: Networks and Operating Systems Chapter 11: Introduction to ... · Networks and Operating Systems Chapter 11: Introduction to Operating Systems (252-0062-00) ... Operating System Applications](https://reader030.fdocuments.net/reader030/viewer/2022040408/5eb5bc17b01d8e28334935cc/html5/thumbnails/65.jpg)
When is the kernel exited?
• Creating a new process
– Including startup
• Resuming a process after a trap
– Exception, interrupt or system call
• User-level upcall
– Much like an interrupt, but to user-level
• Switching to another process