1/139
Me when I don't rember any of the Internet Service Providers nor have I accomplished the HomeWork elements
What is an operating system (OS)?
Software that manages a computer’s resources, making it easier to write and run applications efficiently
Why study operating systems?
To understand how computers work, manage complexity through abstractions, and learn about system design trade-offs.
What are the three main roles of an operating system?
Referee, Illusionist, and Glue.
How does an OS act as a referee?
It manages shared resources, ensures process isolation, and enables communication between processes.
How does an OS act as an illusionist?
It creates the illusion of resources through virtualization, such as virtual memory and processor time-sharing.
How does an OS act as glue?
It provides standard interfaces to hardware, simplifies application design, and facilitates resource sharing.
What are the key factors in evaluating an OS?
Reliability, Security, Portability, and Performance.
What defines an OS’s reliability?
Its ability to consistently perform as designed, minimizing technical errors and maximizing availability.
What is the importance of security in an OS?
It ensures data privacy, enforces security policies, and prevents unauthorized access or system compromise.
What is OS portability?
The ability of an OS to function across different hardware platforms without modification.
What are the three interfaces that define OS portability?
Abstract Machine Interface (AMI), Application Programming Interface (API), and Hardware Abstraction Layer (HAL).
What are key performance metrics for an OS?
Efficiency, fairness, response time, throughput, and predictability.
you are my sweaty
this is true king
What were the three main phases in the history of operating systems?
Expensive hardware, cheap humans
Cheap hardware, expensive humans
Very cheap hardware, very expensive humans
What was characteristic of Phase 1 (1945-1965) in OS history?
Single-user systems
Batch processing for efficiency
Overlapping I/O and computation
Introduction of multiprogramming
What was batch processing, and when was it used?
A system where user jobs were grouped into batches and processed sequentially (1955-1965).
What is multiprogramming, and why was it important?
Running multiple programs concurrently to maximize CPU usage; required memory protection and relocation.
How did interactive timesharing (1970-) improve computing?
Allowed multiple users to interact with a system simultaneously, enabling easier debugging and faster responses.
What are the key requirements for interactive timesharing?
More sharing, more protection, more concurrency, virtual memory, and rapid process switching.
Why did early personal computing systems eliminate multiprogramming?
To simplify the OS, but this led to problems with reliability as programs could crash each other.
What is the difference between parallel and distributed computing?
Parallel computing: Multiple processors in the same machine share resources.
Distributed computing: Multiple processors communicate over a network.
Why are parallel and distributed systems important?
They improve performance, increase reliability, and enable resource sharing.
How did the complexity of OSs evolve over time?
They grew significantly, from simple batch systems to complex multi-user and networked systems like Unix, Windows, and Linux.
What is a process?
A process is a program during execution, consisting of the program code and its execution state.
What are the key components of a process?
Code (program instructions)
Static data
Execution stack (call chain)
Heap (dynamically allocated data)
CPU registers (PC, SP, etc.)
OS resources (open files, PID, execution state
What are the three main states of a process?
Running, Ready, and Blocked.
What is the role of the Process Control Block (PCB)?
Stores execution state, program counter, stack pointer, register contents, memory information, open files, and user ID of a process.
What are the three main roles of an OS?
Referee (resource management), Illusionist (virtualization), and Glue (standardized interfaces).
What is dual-mode execution?
A mechanism where the CPU operates in either user mode (restricted access) or kernel mode (full access) for security and protection.
What are privileged instructions?
Instructions that can only be executed in kernel mode, such as directly accessing I/O, modifying OS memory, or halting the machine.
How does a CPU switch from user mode to kernel mode?
Through exceptions, interrupts, or system calls.
What is an interrupt vector?
A data structure used by the OS to determine the appropriate response when an exception, interrupt, or system call occurs.
What is a system call?
A request by a user-level process to execute a function in the kernel, such as read()
, write()
, or exit()
.
How does a process create a new process in Unix?
Using fork()
, which creates a child process identical to the parent.
What does exec()
do in Unix?
Overlays a process with a new program while keeping the same PID.
What is the purpose of wait()
?
It makes the parent process wait for a child process to terminate and retrieve its exit status.
What is a zombie process?
A terminated process whose parent has not yet collected its status.
What is an orphan process?
A process whose parent has terminated before the child process finishes execution.
How does a process terminate itself?
By calling exit()
, which deallocates resources and notifies the parent.
How can a parent process terminate a child process?
Using the kill()
system call, which sends a signal to the specified process.
What are some common Unix signals used for process control?
SIGHUP
: Hang up (parent process termination)
SIGKILL
: Forcefully terminate a process
SIGCHLD
: Sent to the parent when a child process terminates
What is the purpose of nice()
in process management?
It adjusts the priority of a process to influence scheduling.
What is ptrace()
used for?
Debugging, allowing one process to control another by setting breakpoints and examining memory/registers.
How does sleep()
function in process management?
It suspends a process for a specified amount of time before resuming execution.
What are the five states in the process life cycle?
New, Ready, Running, Blocked, Terminated
What is multiprogramming?
A technique where multiple processes are in memory at once, overlapping I/O and CPU activities to improve utilization and throughput.
What is long-term scheduling?
It determines the degree of multiprogramming by controlling the number of jobs in primary memory.
When does the short-term scheduler execute?
When a process switches from running to blocking
When a process is created or terminated
When an interrupt occurs
What is the difference between preemptive and non-preemptive scheduling?
Non-preemptive: A process runs until it blocks or terminates.
Preemptive: A process can be interrupted and replaced by another process due to a timer or hardware interrupt.
What are the key criteria for evaluating scheduling policies?
CPU Utilization
Throughput
Turnaround Time
Response Time
Waiting Time
What are the goals of an ideal CPU scheduler?
Maximize CPU utilization and throughput
Minimize turnaround time, waiting time, and response time
Ensure predictability and fairness
How does First-Come-First-Served (FCFS) scheduling work?
Processes execute in the order they arrive and run until completion or blocking.
How does Round Robin scheduling work?
Each process runs for a fixed time slice before being moved to the back of the queue.
What is a context switch?
The process of saving the state of one process and loading the state of another.
What is Shortest Job First (SJF) scheduling?
A scheduling policy that selects the process with the least CPU time required.
How does the Multilevel Feedback Queue (MLFQ) scheduling work?
Uses multiple priority queues.
A job starts at the highest priority.
If it uses up its time slice, it moves to a lower priority.
If it blocks before the time slice ends, it moves to a higher priority.
How does the boot sequence of an OS work?
CPU loads the boot program from ROM (BIOS/UEFI).
Boot program checks hardware configuration.
OS kernel is loaded and initializes system structures.
System processes start, and the OS becomes ready for user programs.
What is a thread?
A thread is an abstract entity that executes a sequence of instructions within a process, also known as a "Thread of Control."
How do threads differ from processes?
Threads share the same address space, while processes have separate address spaces.
Thread creation is cheaper than process creation.
Communication between threads is easier than between processes.
Why do programmers use multi-threading?
To better represent the structure of tasks.
To improve performance by allowing computation and I/O operations to overlap.
To take advantage of multi-processor systems.
How does multi-threading improve a web server's performance?
It allows multiple client requests to be handled concurrently, reducing total processing time.
What is the most expensive to switch between: processes or threads?
Processes are more expensive to switch between because they require switching address spaces, whereas threads share the same address space.
What are the five states of a thread?
New, Ready, Running, Blocked, Terminated
What components do threads share within a process?
Address space
Global variables
Heap
What are the two main types of threads?
User-level threads and Kernel-level threads
What is a user-level thread?
A thread that the OS does not know about.
Managed by a thread library in user space.
Switching between threads does not require kernel intervention.
What is a kernel-level thread?
A thread managed by the operating system.
Requires system calls for creation, destruction, and synchronization.
Supports parallelism on multi-core/multi-processor systems.
What are the advantages of user-level threads?
Faster context switching (no kernel involvement).
Custom scheduling policies can be implemented.
No need for system calls when switching threads.
What are the advantages of kernel-level threads?
The OS can schedule individual threads, improving performance.
One thread blocking does not block the entire process.
Can run in parallel on multiple cores/processors.
How do user-level threads handle context switching?
Thread yields control voluntarily.
Thread library saves the current thread’s state.
Scheduler selects a new thread.
New thread’s state is loaded.
How do kernel-level threads handle context switching?
Thread blocks, is interrupted, or voluntarily yields.
Mode switch to kernel mode.
Kernel saves the thread’s state.
Scheduler selects a new thread.
New thread’s state is loaded.
Mode switch back to user mode.
What is the difference between independent and cooperating threads?
Independent threads have no shared state and are deterministic.
Cooperating threads share state, making them non-deterministic but allowing concurrency.
What are the four main flavors of thread implementations?
Single-threaded processes (one thread per process).
User-level multi-threading (threads managed in user space).
Kernel-level multi-threading (threads managed by the OS).
In-kernel threads (threads running within the OS itself).
um I believe in us guys
yaaassss qweeen 🌟
What is a race condition?
A race condition occurs when multiple threads access shared data concurrently, and the final result depends on the timing of execution.
What are the four properties required for correctness in critical sections?
Safety – Only one thread in the critical section at a time.
Liveness – If no threads are in the critical section, a waiting thread must eventually enter.
Bounded Waiting – There is a limit on how long a thread waits before entering.
Failure Atomicity – The system remains consistent even if a thread fails inside the critical section.
What is mutual exclusion?
A principle ensuring that only one thread or process accesses a shared resource at a time.
What is a critical section?
A section of code that must be executed by only one thread at a time to avoid race conditions.
What is an atomic operation?
An operation that cannot be interrupted and runs to completion without interference from other threads.
What is a lock in concurrent programming?
A synchronization mechanism that ensures only one thread can access a shared resource at a time.
What are the two main lock operations?
Lock:Acquire() – Wait until the lock is free, then take it.
Lock:Release() – Free the lock and wake up any waiting threads.
What is busy waiting?
A situation where a thread continuously checks for a condition instead of sleeping, wasting CPU cycles.
What are the problems with busy waiting?
Wastes CPU time.
Causes priority inversion issues.
Not scalable for multiple threads.
How does disabling interrupts help with mutual exclusion?
It prevents context switches while a thread is executing its critical section, ensuring atomic operations.
Why is disabling interrupts not an ideal solution for locking?
It prevents other important system tasks from running.
It only works on a single CPU, not multiprocessor systems.
What is the Test-and-Set instruction used for?
An atomic operation used to implement locks by checking and setting a variable in one step.
What is the problem with using Test-and-Set for locks?
It leads to busy waiting, where threads constantly check for lock availability, consuming CPU resources.
What is priority inversion?
A situation where a high-priority thread is waiting for a lower-priority thread to release a lock, potentially causing delays.
What is a semaphore?
A synchronization primitive used to control access to a shared resource, supporting more general synchronization than locks.
What are the two atomic operations of semaphores?
Down() – Decrements the semaphore; blocks if the count is 0.
Up() – Increments the semaphore; wakes up waiting threads if necessary.
What are the two types of semaphores?
Binary Semaphore – Acts like a lock, with values 0 (locked) and 1 (unlocked).
Counting Semaphore – Tracks multiple available resources and allows multiple threads to proceed.
How can semaphores be used to solve the "Too Much Milk" problem?
By using a binary semaphore to ensure mutual exclusion when checking and buying milk.
When should semaphores be used instead of locks?
When multiple resources are available.
When threads need to coordinate their execution beyond simple mutual exclusion.
How do counted semaphores differ from binary semaphores?
Counted semaphores allow multiple threads to proceed if there are available resources, while binary semaphores only allow one thread at a time.
What does the Up() operation do in a semaphore?
It increments the semaphore value and wakes up a waiting thread if necessary.
I wish I could be as smart as my king Gregory House
I am cooked if you cannot tell. I will donate the remnants of my brain to my dear friends.
What is the Dining Philosophers problem?
N philosophers sit at a table with N chopsticks; each needs two chopsticks to eat and alternates between thinking, getting hungry, and eating.
What is deadlock?
Deadlock occurs when two or more threads are waiting for an event that only the other threads can generate.
How is deadlock different from starvation?
Starvation happens when a thread waits indefinitely for resources, but other threads are using them. Deadlock implies starvation, but not vice versa.
What are the four necessary conditions for deadlock?
Mutual Exclusion – At least one thread holds a resource in a non-sharable mode.
Hold and Wait – A thread holds a resource while waiting for another.
No Pre-emption – A resource cannot be forcibly taken away from a thread.
Circular Wait – A circular chain of waiting threads exists.