Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMPT 300: Operating Systems I Dr. Mohamed Hefeeda

Similar presentations


Presentation on theme: "CMPT 300: Operating Systems I Dr. Mohamed Hefeeda"— Presentation transcript:

1 CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda

2 Course Objective Understand the basic principles of designing and implementing operating systems Why study OS? Be better developer (system and application levels) Be better computer user Use OS concepts in many different CS areas and courses

3 Course Info Textbook Grading Web page
Silberschatz, Galvin, Gagne, Operating System Concepts, (We will refer to it as OSC) Grading Assignments: 25% (problem sets and programming projects) Midterm exam: 25% Final exam: % Web page

4 Topics Operating System Structures Processes and Threads
CPU Scheduling and Process Coordination Memory Management Storage Management and File Systems I/O Systems Security and Protection (time permits)

5 Chapter 1: Introduction

6 Objectives To provide coverage of basic computer system organization
To provide a grand tour of the major operating system components

7 Computer System Structure
Computer system has four components Hardware – provides basic computing resources CPU, memory, I/O devices Operating system Controls and coordinates use of hardware among various applications and users Application programs – define the ways in which system resources are used to solve computing problems Word processors, compilers, web browsers, database systems, video games Users People, machines, other computers

8 Computer System Components

9 Operating System Definition
OS is a program that acts as an intermediary between users and computer hardware OS is a resource allocator Manages all resources Decides between conflicting requests for efficient and fair resource use OS is a control program Controls execution of programs to prevent errors and improper use of the computer OS performs no useful function by itself; It provides environment for programs to do useful work Can you give an example entity from real life? Well, the government!

10 Operating System Goals
Make the computer system convenient to use Execute user programs and make solving user problems easier Emphasized in PCs, handheld devices Use computer hardware in efficient manner Emphasized in large-scale computers with many users and expensive hardware (e.g., airline reservation system) Note: The OS kernel: is a program running at all times Everything else is either a system program (ships with the operating system) or an application program

11 Computer System Organization
One or more CPUs, device controllers connect through common bus to a shared memory

12 Computer System Operation
I/O devices and CPU can execute concurrently Each device controller is in charge of a particular device type has a local buffer I/O is performed from device to local buffer CPU moves data between main memory and local buffers Device controller informs CPU that it has finished its operation by causing an interrupt

13 Interrupt Handling OS preserves state of CPU by storing registers and the program counter The corresponding interrupt handler is called to process the interrupt How would OS locate the correct handler? In many systems (Windows, Linux), an interrupt vector is stored in the lowest memory locations Each entry contains the address of a handler routine in the memory Each interrupt number is mapped to an entry in the interrupt vector

14 Storage Systems: Hierarchy
Speed Cost Volatility Cost Speed

15 Comparison of Storage Systems

16 Caching Caching Information is copied from slower to faster storage performed at many levels in a computer (HW, OS, SW) Faster storage (cache) checked first to determine if information is there If it is, information used directly from cache (fast) If not, data copied to cache and used there

17 Caching Example: Migration of Integer A from Disk to Register
Movement between levels of storage hierarchy can be explicit or implicit Multitasking environments must be careful to use most recent value, no matter where it is in the storage hierarchy Cache consistency

18 Operating System Operations
OS is interrupt (event) driven: sits idle till something happens Interrupts are generated by hardware devices Traps (or exceptions) are software-generated interrupts due to software errors, e.g., divide by zero, illegal memory access Request for operating system services (system calls) OS operates in two modes User mode and kernel mode Mode bit provided by hardware to indicate current mode

19 Operating System Operations (cont’d)
Privileged Instructions Subset of instructions that may harm the system Can only be executed in kernel mode E.g., I/O control, timer management, interrupt management Why dual mode? To enable OS to protect the hardware and itself from users’ codes (which may be buggy and/or malicious), and to protect users from each other If privileged instructions can only be executed in kernel mode, how can users’ codes use them? Using System Calls (interrupts generated by software)

20 Transition from User to Kernel Mode
User’s code issues a system call Mode is changed to kernel mode OS first checks that everything (e.g., parameter values) is in order and legal Then, OS executes system call which may contain multiple privileged instructions mode is set again to user mode

21 More Protection: Timer
Timer to prevent program from holding resources (CPU) for too long, e.g., infinite loop How it works Before giving control to a user program, OS sets a timer to a specific value After period expires, an interrupt is issued and OS regains control OS then decides whether to grant more time for the program or terminate it

22 Multiprogramming in OS
Multiple jobs are kept in memory so that CPU always has something to execute needed for efficiency, a single job may not keep CPU and I/O devices busy at all times One job is selected to run via CPU scheduler When the job has to wait (for I/O for example), OS switches to another job Timesharing (multitasking) CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing

23 Summary OS is a layer between user and hardware to make life easier for user and use hardware efficiently Computer organization CPU(s), memory, and I/O devices connect to a common bus Devices request CPU attention through interrupts Storage hierarchy: speed, cost, volatility Caching: copy frequently-used data to faster storage Multiprogramming: multiple jobs in memory  efficiency Timesharing: frequently switch between jobs  interactive Dual mode operation: user and kernel modes Protect OS and users from each other Privileged instructions executed only in kernel mode Timer to prevent processes from holding resources forever


Download ppt "CMPT 300: Operating Systems I Dr. Mohamed Hefeeda"

Similar presentations


Ads by Google