OS Reading
OS Reading
A program that acts as an intermediary between the user and the computer hardware.
Goals:
o Execute user programs efficiently.
o Make the computer convenient to use.
o Allocate resources fairly.
o Control program execution to prevent errors.
4. Computing Environments
5. OS Structure
6. OS Functions
7. OS Services
9. Special-Purpose Systems
1. Process Concept
2. Process Structure
3. Process States
5. Process Scheduling
6. Context Switching
Producer-Consumer Problem:
o Producer generates data, consumer processes it.
o Uses bounded/unbounded buffer.
o Synchronization required to avoid overwriting or reading empty buffer.
o Semaphores are often used to solve synchronization issues.
3. Types of Threads
4. Thread Libraries
5. Threading Issues
Thread Cancellation:
o Asynchronous: Kills a thread immediately.
o Deferred: Thread checks if it should terminate.
Signal Handling: How threads handle UNIX signals (sent to all threads, specific threads, or a
handler thread).
Thread Pools:
o Instead of creating/destroying threads frequently, a fixed number of threads are
maintained.
o Improves performance and prevents excessive thread creation.
Thread-Specific Data: Some data is unique to each thread, even though threads share memory.
Scheduler Activation: Communication between kernel and thread library to allocate kernel
threads efficiently.
Strategy 1: Yield()
o A thread voluntarily gives up the CPU, allowing other threads to execute.
Strategy 2: Preemption
o OS uses a timer interrupt to force context switching.
Examples of Multithreading
Word Processor: One thread handles keystrokes, another checks spelling, another auto-saves.
Web Server: Multiple threads process user requests simultaneously.
Spreadsheet: One thread updates calculations while another handles user input.