Operating Systems Midterm Revision
Operating Systems Midterm Revision
Tutorial 1
Operating System
Piece of software which:
1. Act as intermediary between user and hardware resources
2. Assign requested resources to processes
3. Manage existing resources
Abstraction: hiding details and complexity of a system presenting a simplified view
1. Performs operations on behalf of programs
2. Introduce file abstraction so programs don’t need to have a disk to operate
3. Transforms computer hardware into multiple virtual computer
4. Can enforce security
Arbitration: Managing access to shared hardware resources
1. Allows devices or memory to be run by more than one user
2. Handles potential access conflicts between processors
Functionalities of OS
1. Execution of programs
Load from secondary memory to main memory
Provides CPU access to program
Remove program from main mem after execution
2. CPU scheduling
Maximize CPU utilization
Minimize response time
3. Input/output management
Tutorial 2
Kernel
Core of the operating System
Responsible for:
1. Process management: creating/ scheduling/terminating processes
2. Memory management: management of main memory/disk during
process execution/ memory allocation
3. File system management: creating/organizing/accessing/controlling files
4. Device management: controlling input/output devices and device
communication
5. System call handling: mechanism used to request services from OS/
through APIs/type of exception
User mode:
Application software
Unprivileged
Limited access to resources
Interrupts (Asynchronous)
1. Signal emitted by hardware when an event needs immediate attention
2. Way to improve processor utilization
3. Most I/O devices are slower that processor
4. Handle them priority based
Exception (Synchronous)
1. Events that interrupt normal execution of a program
2. Caused by errors in the software
Process management:
Creation
o User log in
o Spawned by existing process
Termination
o Normal completion
o Time limit
o Parent termination
o Bounds violation/ Arithmetic error
Scheduling/dispatching
Process switching
Management of process control blocks (contains all info about
process that is needed by OS)
Process (a program in execution)
1. Assign unique process identifier to new process
2. Allocate space in main memory
3. Initialize process control block
4. Set appropriate linkages
5. Create/expand other data structures
Program: group of instructions to carry out a task
Process control block :- Facilitates process management in OS
1. Process identification
Process identifier
Parent identifier
User identifier
2. State information
user Visible registers
control and status registers
stack pointers
3. Control information
a. Scheduling/ state information
b. Process privileges (what memory can be accessed)
c. memory management
d. resource ownership
Dispatcher used to switch from 1 process to another
Fork
1. system call creates a new process
2. copy of current process
3. return values are:
a. 0 (returned from child process)
b. + (succesful)
c. - (unsuccessful)
Tutorial 4
Resource ownership
A process includes a virtual address space to hold the process image
A process may be allocated ownership of resources
Scheduling/execution
Process has an execution state and dispatching priority
Thread
The smallest unit of execution
Can execute independently within the same process
Allow program to perform multiple tasks concurrently
Improves responsiveness
Resource sharing with threads in the same process
Deadlocks may occur from improper synchronization
User-level threads
1. Managed by user space libraries
2. Kernel is unaware of existence of ULT
3. Lightweight/ low overhead
4. Unable to take advantage of multiprocessor systems
5. Blocking system may block all threads
6. Scheduling can be application specific
7. Can run on any operating systm
Kernel-level threads
1. Managed by OS kernel
2. Each thread represented as a separate entity in the kernel with its own
thread control block
3. Threads can be distributed to multiple CPU’s
4. Higher overhead
Jacketing
1. Converts blocking system call into non-blocking system call
2. Thread calls application level I/O routine
3. Within jacket routine there’s code that checks if I/O device is busy
4. If busy thread enters block state and passes control to another thread
Scheduling algorithms
Preemptive: OS can interrupt or suspend execution
First Come First Served (FCFS) non-preemptive
Short job first non-preemptive
Highest response rate next non-preemptive
Round Robin (RR) preemptive
Shortest remaining time next preemptive
Turnaround time = Finish time- Arrival time
Multi-level feedback
1. Four priority levels
2. Quantum length for the highest level 1 time unit and is doubled as we move
down the priority
Types of Tasks
1. Periodic
a. Task repeated after a period time
b. Hard deadlines
2. Aperiodic
a. Unpredictable 1 shot task
b. Soft or no deadlines
3. Sporadic
a. Unpredictable 1 shot task
b. Hard deadlines
Polling server
1. Periodic task used to serve aperiodic requests
2. Released periodically with period Ps
3. Serves pending aperiodic request
4. Suspends itself if:
a. Used its capacity
b. No aperiodic request pending
5. Server capacity replenished