P1L2 - Introduction to Operating Systems
What is monolithic OS? [Monolithic OS]
Any possible system that app can require or hardware could demand is already part of OS.
Which are which? [Abstraction or arbitration quiz]
Arbitration: distributing memory between processes Abstraction: supporting different types of speakers Abstraction: interchangeable access to hard disk or SSD
What does Mac OS Architecture look like?
At core, Mach microkernel implements key primitives like memory management, thread scheduling, IPC including for RPC. BSD: Unix interoperability via BSD command line interface, network I/O All app environments sit above this layer Bottom layer is for development of drivers
Where does OS sit? [What is an operating system?]
Between apps and hardware
How does execution context change during a system call? [System calls]
Change execution context from user process to OS kernel, passing arguments necessary, jumping to memory of kernel to go through instructions for system call. OS operates in privileged mode and can perform whatever operation. Once system call completes, it returns results and control to process, execution context is changed to user mode.
What are some examples of OS? [Operating system examples]
Desktop: Microsoft Windows, family of UNIX-based: Mac OS X, Linux (open source) Embedded: Android, iOS
How are arguments passed in a system call? [System calls]
Either directly or pass their location in memory
What is this? [Modular OS]
Everything can be added as a module, easily customize. OS specifies interfaces that any module must implement to be part of OS. Dynamically depending on workload we can install module that implements interface to make sense for workload. Example is Linux.
What are likely parts of OS? [Quiz]
File system, device driver, scheduler. Not cache memory
What does OS do? [What is an operating system?]
Hide hardware complexity (ie provide socket abstraction for clients), resource management (manage the hardware for apps, ie memory allocation, schedule application on CPU), provide isolation and protection between apps (ie apps can't access each other's memory)
What are examples of system calls? [OS Protection Boundary]
Malloc, open, send
What are basic OS services? [OS Services]
Mapping to hardware: Scheduler: control access to CPU Memory manager: allocate physical memory to apps, isolation block device driver: for example disk Higher level services: File system
What are the other ways OS and applications can interact? From OS to applications [OS Protection Boundary]
OS supports signals, way for OS to pass notifications into applications
What mode is hardware access allowed? [OS Protection Boundary]
Only from kernel mode by operating system kernel
What is a microkernel OS design? [Microkernel]
Only require most basic primitives at OS level. Basic services might include address space, thread. Everything else, all other software components, runs outside of OS kernel at user-level. This requires a lot of inter process interactions. Microkernel will support IPC.
What are included in hardware components? [What is an operating system?]
Processors or CPU, memory, networking devices, storage devices, GPU
What are pros/cons monolithic OS? [Monolithic OS]
Pros: everything included, packaged at same time, compile time optimizations Cons: too much state, code, hard to maintain/debug, large size, requires large memory, performance
What are pros/cons of modular OS? [Modular OS]
Pros: maintainable, smaller codebase, less resource intensive, more memory for apps, performance Cons: indirection can impact performance since we have to go through interface, reduce optimization opportunity (not significant), maintenance can be an issue
Pros/cons of microkernels [Microkernel]
Pros: very small, verifiability of code, good for embedded devices Cons: complexity of software development, portability (very specialized), cost of user/kernel crossing
What are higher level abstractions for OS? [OS elements]
Related to applications OS executes: process, thread Related to hardware resources: file, socket, memory pages
What are OS design principles? [OS design principles]
Separation between mechanism and policy, optimize for common case,
How do OS make services available? [OS Services]
System calls
What happens if in user mode there's an instruction to do a privileged operation? [OS Protection Boundary]
There will be a trap, interrupt application, hardware will switch control to operating system, check what caused trap, verify if it should terminate process or allow.
How does hardware support user/kernel transitions? [Crossing the OS Boundary]
Traps (transfer control to OS)
What are two modes computers support? [OS Protection Boundary]
User (unprivileged) and kernel mode (privileged)
What does a system call entail? [System calls]
User process executing Calls system call because it needs hardware access In the system call control is passed to OS, in privileged mode, trade mode bit = 0 OS executes system call and return results to process Return from system call
What are characteristics of Linux architecture? [Linux and Mac OS Architectures]
Users Standards utility programs Standard library Linux OS Hardware
What is an example of separation between mechanism and policy? [OS design principles]
We want to implement flexible mechanisms that support different policies. For memory management we might use policies: LRU LFU random. Reason is in different settings different policies make more sense
What is an example of optimizing for common case? [OS design principles]
Where will OS be used? What will user want to execute on machine? What are workload requirements? Understand common case then choose policy
What are mechanisms executed by OS? [OS elements]
create, schedule, open, write, allocate
How is OS like a toy shop? [Visual Metaphor]
direct operational resources, enforce working policies, mitigates difficulty of complex tasks
What are policies used by OS? [OS elements]
least recently used, earliest deadline first
What is an OS for? [Lesson Preview]
special piece of software that abstracts (to simplify what hardware looks like) and arbitrates (to manage and oversee and control hardware use) the use of a computer system
How is privileged mode implemented? [OS Protection Boundary]
In kernel mode there's special bit in CPU that's set any instruction that manipulates hardware is allowed to execute. In user mode this bit is not set.
How do OS and applications interact? [OS Protection Boundary]
Interaction between application and OS can be via system call interface. OS export system call interface for applications to explicitly invoke
What are issues with user/kernel transitions? [Crossing the OS Boundary]
Involves a lot of instructions (expensive), issues of hardware cache usage: app performance is dependent on cache, when we do system call, OS will replace content in cache and this will have impact on application performance since it can't access its data in cache
What are different system calls? [Quiz]
KILL: send signal to process SETGID: set group identity of process mount: mount file system sysctl: read/write system parameters
What does Linux kernel consist of?
Kernel consists of several logical components with well defined functionality and interfaces. These components can be independently modified/replaced
What must application do to make a system call? [System calls]
Write arguments, save relevant data in well defined location, make system call
Is it allowed to switch between user and kernel mode? [OS Protection Boundary]
Yes, supported by hardware