











































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












































Operating system - Answer -- Acts as an intermediary between the user and the computer hardware.
Multitasking - Answer - Ability to run multiple programs on the same machine Multiprogramming - Answer - Multiple programs can run concurrently Benefits of concurrency - Answer - Can run multiple programs simultaneously Better resource utilization Better average response time Better performance Thread - Answer - A sequential execution stream Address space - Answer - Contains all necessary states to run a program Process - Answer - An address space and at least one thread of execution Difference between process and program - Answer - A program is just a collection of statements, a process is a running instance of a program. Uniprogramming - Answer - Running one process at a time Multithreading - Answer - having multiple threads per address space Dispatching loop - Answer - Run thread Save States Choose new thread Load states from new thread Context switch - Answer - Switching the CPU from one thread/process to another Thread state diagram - Answer - Ready - > Running - > Blocked - >Ready etc. Ready-> Running: Scheduled Running-> Ready: yield, timer Running - > Blocked: I/O request Blocked - > Ready: IO complete Amdahl's Law - Answer - S = %of sequential computations N = cores x = 1/(S + (1-S/N)) Booting sequence - Answer - Jump Load from BIOS
Round Robin - Answer - Jobs take predetermined length turns on the CPU. Shorter response time, fair sharing of cpu not all jobs preemptive, not good for jobs of the same length Preemptive Shortest Job first - Answer - Non preemptive Runs whichever job is shortest first. Runs best when jobs are usually short, degradation for longer jobs. Turns into FIFO if jobs are the same length. Shortest time remaining first - Answer - Preemptive version of shortest job first. Short jobs do not get stuck behind anything under SRTF Multilevel Feedback Queue - Answer - Uses multiple queues with different priorities Round robin: Run highest priority jobs first. Jobs start in highest priority. If time expires they go down, if time does not expire they go up. Approximates SRTF, CPU jobs lose priority, I/O jobs stay near the top. Counter measure: Aging Lottery Scheduling - Answer - Adaptive approach to address fairness. Every process is given a number of tickets based on its size, shorter jobs get more. Every time slice a random "ticket" is chosen. Each job gets at least one ticket Atomic operation - Answer - An atomic operation runs to completion, it is all or nothing Race conditions - Answer - occur when threads share data and their results depend on the timing of their executions Independent Threads - Answer - No states shared with other threads Deterministic computation Reproducible Cooperating threads - Answer - Shared states Non deterministic Non reproducible Why?
Shared resources Speedup from using different resources Modularity Mutual Exclusion - Answer - Ensures one thread can do something without the interference of other threads Critical section - Answer - A piece of code that only one thread can execute at a time Code verification - Answer - Test arbitrary interleaving of locking and checking locks. Difficult to verify as two threads have different code, difficult to generalize to N threads Busy Waiting - Answer - Hogging CPU cycles while a thread is waiting for a lock. Can be avoided with a waiting queue Ways to implement locks - Answer - High level atomic operations: locks, semaphores, monitors, send/receive Low level atomic operations: load/store, interrupt disables, test and set Semaphore - Answer - Type of generalized lock consisting of a nonnegative integer value and two operations P() waits for the semaphore to become positive then decrements it by one V() increments semaphore by 1 and wakes up a thread at P() Semaphores vs Integers - Answer - No negative values Only operations are P() and V() Operations are atomic. Two uses of semaphores - Answer - Mutual exclusion Scheduling, semaphore usually has an initial value of 0 Safety - Answer - Mutual exclusion, only one thread is in the critical section at a time Shared resources protected Locks are acquired at entrance to Liveness - Answer - Progress. If more than one thread is interested in executing the critical section, some processes will eventually do so (deadlock free)
to structure kernel strictly in layers Modules - Answer - Most modern operating systems implement kernel modules:
Process Scheduling - Answer - To maximize CPU utilization, kernel quickly switches processes onto CPU for time sharing Process "scheduler" selects among available processes for next execution on CPU Kernel maintains scheduling queues of processes:
Process Creation - Answer - Parent process creates children processes, which, in turn create other processes, forming a tree of processes The process is identified and managed via a process identifier (pid) Design Choices for Process Creation - Answer - 1. Resource Sharing
Require parent-child relationship between communicating processes Named Pipes - Answer - 1. Named pipes are more powerful than ordinary pipes
Throughput: # of processes that complete execution per time unit Turnaround time: the time to execute a particular process from the time of submission to the time of completion Waiting time: the total time spent waiting in the ready queue Response time: the time it takes from when a request was submitted until the first response is produced Scheduling Algorithms - Answer - First-come, first-served scheduling Shortest-job-first scheduling Priority scheduling Round-robin scheduling Multilevel queue scheduling Multilevel feedback queue scheduling Thread Scheduling - Answer - OS kernel schedules kernel threads System-contention scope - Answer - competition among all threads in system Multiple-Processor Scheduling - Answer - Approaches to multiple-processor scheduling: Asymmetric Multiprocessing
Priority Inversion - Answer - a higher priority process is indirectly preempted by a lower priority task Bounded-Buffer/Producer-Consumer Problem - Answer - Two processes, the producer and the consumer share n buffers:
writers: can both read and write The readers-writers problem: