Learning Outcomes

• High-level understand what is an operating Introduction to and the role it plays Systems • A high-level understanding of the structure of operating systems, applications, and the relationship between them. Chapter 1 – 1.3 • Some knowledge of the services provided by Chapter 1.5 – 1.9 operating systems. • Exposure to some details of major OS concepts.

2

What is an Operating System?

3 4

Block Diagram of Haswell Platform Architecture http://www.pcquest.com

Role 1: The Operating System is Disk Users an Abstract Machine

• Extends the basic hardware with added Memory functionality • Provides high-level abstractions – More programmer friendly CPU – Common core for all applications Network • E.g. Filesystem instead of just registers on a disk controller Bandwidth • It hides the details of the hardware – Makes application code portable

5 6

1 Structural (Implementation) View: the Role 2: The Operating System Operating System is the Privileged is a Resource Manager Component • Responsible for allocating resources to users and processes Applications Applications Applications

• Must ensure User Mode Requests (System Calls) – No Starvation Privileged Mode – Progress – Allocation is according to some desired policy Operating System • First-come, first-served; Fair share; Weighted fair share; limits (quotas), etc… – Overall, that the system is efficiently used Hardware

7 8

The Operating System is Operating System Kernel Privileged • Portion of the operating system that is • Applications should not be able to interfere or bypass running in privileged mode the operating system – OS can enforce the “extended machine” • Usually resident (stays) in main memory – OS can enforce its resource allocation policies • Contains fundamental functionality – Prevent applications from interfering with each other – Whatever is required to implement other services Applications Applications Applications – Whatever is required to provide security User Mode Privileged Mode • Contains most-frequently used functions Operating System

• Also called the nucleus or supervisor Hardware 9 10

Delving Deeper: The Structure of a Computer System The Structure of a Computer System

Application Application Application

System Libraries System Libraries System Libraries

User Mode User Mode Kernel Mode Kernel Mode OS interacts via load and store instructions Device Device Operating System OS to all memory, CPU and device registers, Device Device and interrupts Memory Memory

11 12

2 The Structure of a Computer System The Structure of a Computer System

Applications interact with Interaction via themselves and via Application Application System Calls function calls to library procedures System Libraries System Libraries User Mode User Mode Kernel Mode Kernel Mode

Device OS Device OS Device Device Memory Memory

13 14

Privilege-less OS A Note on System Libraries

• Some Embedded OSs have System libraries are just that, libraries of support no privileged component functions (procedures, subroutines) – e.g. PalmOS, Mac OS 9, – Only a subset of library functions are actually systems calls RTEMS • strcmp(), memcpy(), are pure library functions – Can implement OS – manipulate memory within the application, or perform computation functionality, but cannot • open(), close(), read(), write() are system calls enforce it. – they cross the user-kernel boundary, e.g. to read from disk device – Implementation mainly focused on passing request to OS and returning • All software runs together result to application • No isolation – System call functions are in the library for convenience • One fault potentially brings down • try man syscalls on entire system

15 16

Major OS Concepts Operating System Software (Overview) • Fundamentally, OS functions the same way as ordinary computer Application • Processes software • Concurrency and deadlocks – It is a program that is executed System Libraries (just like applications) User Mode • Memory management – It has more privileges • Operating system relinquishes Kernel Mode • Files control of the processor to execute other programs Device OS • Scheduling and resource management – Reestablishes control after • System calls Device • Information Security and Protection • Interrupts (especially timer Memory interrupts)

17 18

3 Memory Processes • Minimally consist of three segments • A program in execution – Text Stack • An instance of a program running on a computer • contains the code (instructions) – Data • The entity that can be assigned to and executed on a • Global variables processor – Stack Gap • A unit of resource ownership • Activation records of procedure/function/method • Local variables • Note: – data can dynamically grow up Data • E.g., malloc()-ing – The stack can dynamically grow down Text • E.g., increasing function call depth or recursion

19 20

Multiple processes creates Process state concurrency issues

• Consists of three components – An executable program code • text – Associated data needed by the program • Data and stack – Execution context of the program • Registers, program counter, stack pointer • Information the operating system needs to manage the process – OS-internal bookkeeping, files open, etc… (a) A potential deadlock. (b) an actual deadlock. 21 22

Memory Management • The view from thirty thousand feet – Process isolation • Allows programmers to address • Prevent processes from accessing each others data – Automatic allocation and management memory from a logical point of view • Users want to deal with data structures – Gives apps the illusion of having RAM to • Users don’t want to deal with physical memory directly themselves – Protection and access control – Logical addresses are independent of • Still want controlled sharing other processes – OS services – Provides isolation of processes from each • Virtual memory other • File system • Can overlap execution of one process

23 while swapping in/out others to disk. 24

4 Virtual Memory Addressing File System

• Implements long-term store • Information stored in named objects Memory management unit called files (hardware) translates program memory addresses to main memory addresses.

25 26

Example File System Scheduling and Resource Management • Fairness – give equal and fair access to all processes • Differential responsiveness – discriminate between different classes of jobs • Efficiency – maximize throughput, minimize response time, and accommodate as many uses as possible

27 28

Operating System Internal Classic Operating System Structure? Structure • The layered approach a) Processor allocation and multiprogramming b) Memory Management c) Devices a b c d e d) File system e) Users – Each layer depends on the inner layers

29 30

5 Operating System The Monolithic Operating Structure System Structure • In practice, layering is only a guide • Also called the – Operating Systems have many “spaghetti nest” interdependencies approach • Scheduling on virtual memory – Everything is • Virtual memory (VM) on I/O to disk tangled up with • VM on files (page to file) everything else. • Files on VM (memory mapped files) • Linux, Windows, • And many more… ….

31 32

The Monolithic Operating System Structure • However, some reasonable structure usually prevails

Bowman, I. T., Holt, R. C., and Brewster, N. V. 1999. Linux as a case study: its extracted software architecture. In Proceedings of the 21st international Conference on Software Engineering (Los Angeles, California, United States, May 16 - 22, 1999). ICSE '99. ACM, 33 34 New York, NY, 555-563. DOI= http://doi.acm.org/10.1145/302405.302691

The End

35

6