A layer between end user applications and the hardware, allowing applications to be developed without having to be aware of all hardware specifics
Operating system
Transforms primitive and awkward hardware architecture into beautiful abstractions
Provides abstractions to application programs and manages complex systems while allocating resources in an orderly and controlled manner
The evolution of computer technology can be categorized into five generations, starting from vacuum tubes to mobile computers
Central Processing Unit (CPU)
A key component of modern computers, responsible for executing instructions and storing temporary values
CPU performance improvements
Techniques like pipelining, multithreading, and multicore processors
Specialized processors like Graphics Processing Units (GPUs) have also contributed to the advancement of parallel computations
Memory hierarchy
L1 cache
L2 cache
Main memory (RAM)
ROM
Flash memory
Magnetic disks (HDDs)
Cheaper and have more capacity than RAM, but slower
Solid State Drives (SSDs)
Faster and use flash memory, but more expensive
Hybrid drives
Combine SSDs and HDDs for high-speed access without compromising capacity
Virtual memory
A solution for programs that don't fit in existing memory, using disk space to temporarily store information
I/O device
Consists of a controller and the device itself, with the controller accepting commands from the operating system
Device drivers
Used to minimize operating system complexity and created by vendors for each supported operating system
I/O methods
1. Busy waiting
2. Interrupt processing
3. Direct Memory Access (DMA)
Types of operating systems
Mainframe
Server
Multiprocessor
Personal computer
Handheld computer
Embedded
Sensor node
Real-time
Smart card
Process
A program in execution, associated with an address space and a set of resources
Process A creates two child processes, B and C, while Process B creates three child processes, D, E, and F
Process information
Process ID
Name
User
Executable file
Register values
Pseudo-parallelism
In multiprogramming systems, CPUs quickly switch from process to process, giving the illusion of parallelism even with just one CPU
Process creation
1. System initialization
2. Process creation system call
3. User request
4. Initiation of a batch job
Process termination
Normal and error exits, fatal errors, and being killed by another process
Process types
Interactive processes (e.g. file explorer, web browser)
Daemons (work in the background and react to specific occurrences)
Process states
Running
Ready
Blocked
Process table entry
Includes various fields that provide information about a process
CPU utilization
Can be approximated as 1 minus the product of the probability of a process waiting for I/O and the number of processes in memory
Thread
Supports parallelism and shared address space, with lower overhead than creating a process
Multithreading examples
Word processor with three threads
Multithreaded Web server with dispatcher and worker threads
Thread states
Running
Ready
Blocked
Thread creation
A single thread is present which can create new threads, with the calling thread usually receiving an identifier for the new thread
Thread termination
Analogous to process termination, with some systems allowing threads to wait for others to finish in a "join" operation
POSIX Threads (Pthreads)
A standard API for thread management, implemented by most POSIX OSes
User-level threads
Allow for customization of scheduling algorithms and can be implemented on OSes with no thread support, making context switching simple and fast
User-level threads disadvantages
Blocking system calls affect all threads in a process, relying on voluntary CPU relinquishment
Kernel-level threads
Offer advantages such as transparent use of blocking system calls, no need for new nonblocking system calls, and page faults caused by one thread not affecting others
Interprocess communication (IPC)
Processes in multiprocess systems need to communicate to pass relevant information, prevent simultaneous access to exclusive resources, and work with appropriate sequencing of events
Race conditions
Occur when multiple processes access shared data simultaneously, leading to unpredictable results
Mutual exclusion
A technique used to avoid race conditions by ensuring that processes accessing shared resources do not overlap in their critical regions
Good solution to race conditions
Ensures no two processes are simultaneously inside their critical regions, prevents processes running outside their critical regions from blocking others, and ensures no process waits indefinitely to enter its critical region