• 140 likes • 211 Views
This abstract explores the components of a computer system, focusing on the role of the operating system as an intermediary between users and hardware, detailing its goals, components, and services. It delves into process and memory management, file and I/O system management, networking, protection systems, and more. The text elucidates how operating systems coordinate machine activities, manage processes, and handle competition for resources, discussing concepts such as program vs. process, process status, and context switching. It also addresses handling resource competition, using examples like semaphores and discussing deadlock scenarios and solutions.
E N D
Operating Systems CSC 2001
Abstract view of computer system components User User User Application programs Operating System Hardware
Operating systems • Controls overall operation of computer • An OS is a program that acts as an intermediary between a user of a computer and the computer hardware. Its purpose is to provide an environment in which a user can execute programs. • Goals • convenience • efficiency
OS components/services • Process management • Main-memory management • File management • I/O system management • Secondary storage management • Networking • Protection system • Command-interpreter system
Overview • Earlier, what is an OS and, at a high level, what does it do. • Now, look in more details at… • Coordinating machine activities • Managing competition for machine resources
Coordinating the Machine’s Activities • Section 3.3 • Program vs. Process • Process has a status • Where it is in the program (program counter) • CPU registers • Associated memory cells • snapshot of process
Managing processes • scheduler • maintains list of processes • adds, deletes • process table • process id, priority, memory area, ready or waiting
Managing processes • dispatcher • manages execution of processes • decides who gets next chunk of time on CPU • switches CPUs attention from one process to another • changes out process states (snapshots) • process switch (context switch)
Process switching • Process execution begins along with interrupt timer • Process runs for a time slice • Interrupt is generated • Process state is saved • Control returned to dispatcher • Process state is swapped with another one • Timer starts and new process is executed
Context switching • A context switch is not a free operation. • Just like you and me, the system must work to make a context switch. • However, since much time is wasted waiting for external devices, being able to do something else while a process is waiting for something else to occur, overall efficiency is generally improved.
Handling competition for resources • Section 3.4 • Managing access to machine resources • Often multiple processes want to access the same resource at the same time • Examples?
Semaphores • A flag for whether or not the resource is available • Problem of an interrupt in the middle of setting the flag • Test-and-set instruction (single step)
Deadlock • Process 1: has printer, waiting for the tape drive • Process 2: has tape drive, waiting for printer • What’s wrong here? • Solutions • Try to avoid a deadlock • Force a process to release a held resource