Download presentation
Presentation is loading. Please wait.
1
OS Fall ’ 02 Introduction Operating Systems Fall 2002
2
OS Fall ’ 02 What is Operating System? It is a program! It is the first piece of software to run after boot It coordinates the execution of all other software User programs It provides various common services needed by users and applications
3
OS Fall ’ 02 Today ’ s plan Operating system functionality Hardware support for the operating system Course overview, bibliography, administrative questions
4
OS Fall ’ 02 The Operating System controls the machine User Application Operating System Hardware OS Kernel Hard ware gcc gdb emacs vi date grep xterm netscape diff
5
OS Fall ’ 02 A better picture Hardware Operating System Privileged instructions System calls Machine instructions Application One Hardware One Operating System Many applications
6
OS Fall ’ 02 A typical scenario 1.OS executes and schedules an application to run 2. Application runs CPU executes app ’ s instructions OS is not involved 3.The system clock interrupts the CPU Clock interrupt handler is executed The handler is the OS function
7
OS Fall ’ 02 A typical scenario (continued) 4. In handler: OS chooses another application to run Context switch 5. The chosen app. runs directly on the hardware 6. The app. performs a system call to read from a file
8
OS Fall ’ 02 A typical scenario (continued) 7.The sys. call causes a trap into the OS OS sets up the things for I/O and puts the application to sleep OS schedules another application to run 8.The third application runs Note: At any given time only one program is running: OS or a user application
9
OS Fall ’ 02 The running application state diagram Application code runs OS runs Sleep Ready To run Interrupt/ System call Wait for I/O completion I/O completed Schedule Resume execution of the app. code
10
OS Fall ’ 02 A question The operating system gets an input, performs a computation, produces an output, and quits Yes or no? The answer: No The operating system is a reactive program
11
OS Fall ’ 02 The OS is a reactive program It is idly waiting for events When an event happens, the OS reacts It handles the event Schedules another application to run The event handling must take as little time as possible Event types Interrupts and system calls
12
OS Fall ’ 02 The OS performs Resource Management Resources for user programs CPU, main memory, disk space OS internal resources Disk space for paging memory (swap space) Entries in system tables Process table, open file table Statically allocated
13
OS Fall ’ 02 CPU management How to share one CPU among many processes Time slicing: Each process is run for a short while and then preempted Scheduling: The decision about which application to run next
14
OS Fall ’ 02 Memory management Programs need main memory frames to store their code, data and stack The total amount of memory used by currently running programs usually exceed the available main memory Solution: paging Temporarily unused pages are stored on disk (swapped out) When they are needed again, they are brought back into the memory (swapped in)
15
OS Fall ’ 02 The OS supports abstractions Creates an illusion that each application got the whole machine to run on In reality: an application can be preempted, wait for I/O, have its pages being swapped out, etc … A tree-like file system organization Disk controllers can only write/read blocks
16
OS Fall ’ 02 Hardware support for OS Support for executing certain instructions in a protected mode Support for interrupts Support for handling interrupts Support for system calls Support for other services
17
OS Fall ’ 02 CPU execution modes CPU has (at least) 2 execution modes: User mode Kernel mode Supervisor mode, privileged mode, monitor mode, system mode The execution mode is indicated by a bit in the processor status word (PSW) Some CPU instructions are available only when executing in the kernel mode
18
OS Fall ’ 02 Kernel Mode OS kernel is a collection of functions responsible for the most basic services OS kernel executes in the kernel mode Privileged instructions: To load/store special CPU registers To map memory pages to the address space of a specific process Instructions to set the interrupt priority level Instructions to activate I/O devices
19
OS Fall ’ 02 Protecting Kernel mode Is it possible for the user program to cause the CPU to enter kernel mode? Yes: This must be possible (system call) The problem: how to prevent the user program from executing privileged instructions? Solution: change the program counter (PC) to point to the OS code upon switch
20
OS Fall ’ 02 Handling interrupts Interrupts cause the CPU to enter kernel mode The address of the kernel function to execute is loaded from the interrupt vector The interrupt vector address and the interrupt numbering is a part of the hardware specification Handlers are registered during the boot
21
OS Fall ’ 02 Interrupt types (I) Asynchronous interrupts are generated by external devices at unpredictable times Clock interrupt is the basis for time slicing: Update the system time, preempt/schedule processes I/O device interrupt Informs the OS about completion of a requested I/O
22
OS Fall ’ 02 Interrupt types (II) Internal (synchronous) interrupts are generated synchronously by CPU as a result of an exceptional condition An error condition: the application is trying to perform an illegal operation: E.g., division by 0, issuing a privileged instr., … The handler typically kills the application A temporary problem: E.g., the requested page is not in the memory Handling: bring the page into the memory
23
OS Fall ’ 02 System calls Used to request a service from the OS A collection of the system calls is the OS API Packaged as a library Typical system calls Open/read/write/close the file Get the current time Create a new process Request more memory
24
OS Fall ’ 02 Handling system calls An application executes a special trap (syscall) instruction Causes the CPU to enter kernel mode and set PC to a special system entry point (gate routine) The gate routine address is typically stored in a predefined interrupt vector entry Intel architecture: int[80] A single entry serves all system calls (why?)
25
OS Fall ’ 02 An example open( “ /tmp/foo ” ): store the system call number and the parameters in a predefined kernel memory location; trap(); retrieve the response from a predefined kernel memory location; return the response to the calling application; trap(): PC:=&int[80]; // transfer control to the gate routine Gate routine: switch(sys_call_num) { case OPEN: … }
26
OS Fall ’ 02 Other hardware support Translating virtual address into a physical address Assist in supporting the virtual memory abstraction Support for “ used ” bits for memory pages Helps to determine which pages can be swapped out when needed
27
OS Fall ’ 02 What we are going to study Performance evaluation (brief) Process handling Process concept, scheduling, concurrency control Memory management Paging, virtual memory File system
28
OS Fall ’ 02 Advanced topics Distributed systems Communication, networking, middleware Other possible topics: Reliable distributed systems Real-time systems Parallel systems Modern storage architectures
29
OS Fall ’ 02 Bibliography Notes by Dror Feitelson Will be published weekly Operating System Concepts, by A. Silberschatz, P. Galvin, G. Gagne Operating Systems Internals and Design Principles, by W. Stallings See the notes for more references
30
OS Fall ’ 02 Next: Performance evaluation
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.