Podcast
Questions and Answers
How does multiprogramming increase CPU and I/O utilization?
How does multiprogramming increase CPU and I/O utilization?
Multiprogramming overlaps the demands for the CPU and I/O devices from various users, ensuring the CPU always has something to execute and allowing multiple tasks to run on different I/O devices.
In a time-sharing system, what advantage do users experience because of the quick response times?
In a time-sharing system, what advantage do users experience because of the quick response times?
Users can interact with the computer while programs are running, often without noticing delays, due to the system's rapid switching between tasks.
Explain why ensuring the same degree of security in a time-shared machine as in a dedicated machine is difficult.
Explain why ensuring the same degree of security in a time-shared machine as in a dedicated machine is difficult.
Any protection scheme devised by humans can be fallible, and the more complex the scheme, the harder it is to ensure its correct implementation and security.
Why is it important for an operating system to be interrupt-driven?
Why is it important for an operating system to be interrupt-driven?
What is the purpose of a mode bit in the context of privileged instructions, and where is it typically located?
What is the purpose of a mode bit in the context of privileged instructions, and where is it typically located?
Why is the Set value of timer
instruction typically designated as privileged?
Why is the Set value of timer
instruction typically designated as privileged?
Why must the access I/O device
instruction be privileged?
Why must the access I/O device
instruction be privileged?
Describe how system calls bridge the gap between user-level processes and the operating system.
Describe how system calls bridge the gap between user-level processes and the operating system.
Name three methods for passing parameters from a user program to the OS during a system call.
Name three methods for passing parameters from a user program to the OS during a system call.
What actions does the kernel take during a context switch to ensure proper execution?
What actions does the kernel take during a context switch to ensure proper execution?
In the context of process management, what defines a 'zombie process,' and why is it problematic?
In the context of process management, what defines a 'zombie process,' and why is it problematic?
Explain the key difference between shared memory and message passing as inter-process communication mechanisms.
Explain the key difference between shared memory and message passing as inter-process communication mechanisms.
Contrast synchronous and asynchronous communication in the context of inter-process messaging.
Contrast synchronous and asynchronous communication in the context of inter-process messaging.
What are the key distinctions between user-level threads and kernel-supported threads?
What are the key distinctions between user-level threads and kernel-supported threads?
Define what is meant by a 'critical section' in concurrent programming.
Define what is meant by a 'critical section' in concurrent programming.
Explain the 'progress' requirement for solutions to the critical-section problem.
Explain the 'progress' requirement for solutions to the critical-section problem.
Explain what an atomic instruction is and why atomicity is critical in the context of synchronization primitives such as wait
operations.
Explain what an atomic instruction is and why atomicity is critical in the context of synchronization primitives such as wait
operations.
What is a spinlock, and explain its advantage and disadvantage as a synchronization mechanism.
What is a spinlock, and explain its advantage and disadvantage as a synchronization mechanism.
Why are spinlocks primarily used on multiprocessor systems rather than single-processor systems?
Why are spinlocks primarily used on multiprocessor systems rather than single-processor systems?
Describe the role and function of pthread_mutex_lock(pthread_mutex_t *mutex)
in multi-threaded programming.
Describe the role and function of pthread_mutex_lock(pthread_mutex_t *mutex)
in multi-threaded programming.
Explain the primary distinction between short-term, medium-term, and long-term scheduling.
Explain the primary distinction between short-term, medium-term, and long-term scheduling.
Why is distinguishing between I/O-bound and CPU-bound programs important for a scheduler?
Why is distinguishing between I/O-bound and CPU-bound programs important for a scheduler?
Why is a transition from the WAITING state to the RUNNING state considered illegal?
Why is a transition from the WAITING state to the RUNNING state considered illegal?
Explain how optimizing response time might reduce overall CPU utilization.
Explain how optimizing response time might reduce overall CPU utilization.
Discuss why shortest job first (SJF) and priority-based scheduling algorithms could lead to starvation.
Discuss why shortest job first (SJF) and priority-based scheduling algorithms could lead to starvation.
What would be the primary disadvantage of implementing duplicated pointers in the ready queue of a Round Robin scheduling algorithm?
What would be the primary disadvantage of implementing duplicated pointers in the ready queue of a Round Robin scheduling algorithm?
How could you modify the basic RR algorithm to achieve the same effect without the duplicate pointers?
How could you modify the basic RR algorithm to achieve the same effect without the duplicate pointers?
What is the difference between turnaround and waiting time for a process?
What is the difference between turnaround and waiting time for a process?
Why might be the the SJF algorithm still be beneficial even if it might not be the ideal option for the selected workload?
Why might be the the SJF algorithm still be beneficial even if it might not be the ideal option for the selected workload?
State one instance of when to use each system call function.
State one instance of when to use each system call function.
Flashcards
Operating System Purposes
Operating System Purposes
Provides an environment for users to execute programs, manages I/O, supervises program execution, and controls computer resources.
Multiprogramming System
Multiprogramming System
A system where several programs reside in memory concurrently, switching among them for efficient processing and minimal idle time.
Advantage of Multiprogramming
Advantage of Multiprogramming
Increases CPU and I/O utilization by overlapping demands from various users.
Timesharing/Multitasking
Timesharing/Multitasking
Signup and view all the flashcards
Advantage of Time-sharing
Advantage of Time-sharing
Signup and view all the flashcards
Implementing Multitasking
Implementing Multitasking
Signup and view all the flashcards
Problems in Multi-user Systems
Problems in Multi-user Systems
Signup and view all the flashcards
OS is Interrupt Driven
OS is Interrupt Driven
Signup and view all the flashcards
Privileged Instruction
Privileged Instruction
Signup and view all the flashcards
User Mode attempting to run Privileged Instruction
User Mode attempting to run Privileged Instruction
Signup and view all the flashcards
Atomic instruction
Atomic instruction
Signup and view all the flashcards
Zombie Process
Zombie Process
Signup and view all the flashcards
Shared Memory vs. Message Passing
Shared Memory vs. Message Passing
Signup and view all the flashcards
Synchronous vs. Asynchronous Communication
Synchronous vs. Asynchronous Communication
Signup and view all the flashcards
User-Level Threads
User-Level Threads
Signup and view all the flashcards
Kernel-Supported Threads
Kernel-Supported Threads
Signup and view all the flashcards
Critical Section
Critical Section
Signup and view all the flashcards
Critical-Section Problem
Critical-Section Problem
Signup and view all the flashcards
Requirements for Critical Section Solution
Requirements for Critical Section Solution
Signup and view all the flashcards
Mutual Exclusion
Mutual Exclusion
Signup and view all the flashcards
Spinlock
Spinlock
Signup and view all the flashcards
Short-Term (CPU) Scheduler
Short-Term (CPU) Scheduler
Signup and view all the flashcards
Medium-Term Scheduler
Medium-Term Scheduler
Signup and view all the flashcards
Long-Term (Job) Scheduler
Long-Term (Job) Scheduler
Signup and view all the flashcards
Waiting -> Running
Waiting -> Running
Signup and view all the flashcards
Running -> Waiting
Running -> Waiting
Signup and view all the flashcards
Scheduling algorithms
Scheduling algorithms
Signup and view all the flashcards
Study Notes
Purposes of an Operating System
- Provides a user-friendly environment for program execution.
- Manages I/O device operations and control.
- Supervises user program execution, preventing errors.
- Controls computer resources and provides a base for application creation.
Multiprogramming Systems
- Several programs reside in memory simultaneously.
- Enables task switching for efficient processing and reduces idle time.
- Increases CPU and I/O utilization.
- Achieves efficiency by overlapping CPU and I/O demands from different users.
- Maximizes CPU use by having something ready to execute.
- Increases I/O utilization by running multiple tasks on different I/O devices.
Time-Sharing (Multitasking) Systems
- Allow users to perform multiple tasks at once using scheduling and multiprogramming.
- Enables interactive systems for multiple users.
- Rapidly switches the CPU between users.
- Programs read inputs from the terminal, with output displayed immediately.
- Increases CPU and I/O utilization, allows user interaction, and provides short response times.
- User programs experience quick response times, often in milliseconds, even with concurrent programs.
- Implemented by giving each user a time-share in round-robin fashion, with jobs continuing until the time-slice ends.
- CPU switches between jobs when the current process waits for an event, like I/O, without requiring timer interrupts.
- A context switch will occur when a job needs to wait.
Security in Multiprogramming and Time-Sharing Environments
- Multiple users sharing a system can lead to security issues.
- Problems include stealing or copying programs/data and unauthorized use of system resources like CPU, memory and disk space.
- Achieving the same level of security as in a dedicated machine is unlikely due to the fallibility of protection schemes.
- More complex schemes are harder to fully trust.
Operating Systems as Interrupt-Driven
- The OS waits for an event (signalled by an interrupt) when idle.
- This happens when no processes are running, no I/O is being serviced, and no users are interacting.
Privilege Instructions
- Hardware instructions executable only in monitor/system/supervisory mode.
Implementation of Privilege Instructions
- Hardware adds a mode bit: '1' for monitor, '0' for user mode.
- One bit differentiates between privilege and non-privilege instructions in each machine code.
- The OS sets the bit to user mode before giving control to user programs.
- Hardware switches the bit to monitor mode during a trap or interrupt.
- The OS can also set the bit to the system mode.
Hardware Response to Privilege Instruction Attempts in User Mode
- Hardware identifies it as an illegal instruction.
- The hardware sends a trap to the OS.
Privileged Instructions and Consequences of Not Privileging
- Set Value of Timer: Privileged, or users can change the timer, disrupting correct system operation.
- Read the Clock: Not privileged.
- Clear Memory: Privileged, or users could accidentally/intentionally delete memory.
- Turn-Off Interrupts: Privileged, or users could crash the system by turning off interrupts.
- Switch from User to Monitor Mode: Privileged; otherwise, all users can access system resources.
- Modifying Base and Limit Registers: Privileged, or users can increase their memory allocation.
- Issue a Trap Instruction: Not privileged, as system calls are traps used by user processes..
- Access I/O Device: Privileged, otherwise novice users may attempt damaging I/O device access.
- **Modify Entries in Device-Status Table: Privileged; modifying OS-managed device info can damage the system.
System Calls
- Allow user-level processes to request OS services, including I/O instructions.
- Parameters are passed to the OS, in a register, in a memory location or in a stack
Unix System Calls Categories
- Process Control
- File Manipulation
- Device Manipulation
- Information Maintenance
- Communication
Context Switch Actions
- Saving the current process state to its Process Control Block (PCB).
- Loading the next state into the processor registers from the PCB.
- Updating the Program Counter to the next instruction for execution.
Information for Context Switching
- Process State
- Program Counter
- CPU Registers
- CPU Scheduling Information
- Memory Management Information
- Accounting Information
Process Creation
- A code with three fork() calls creates 8 processes.
- The first fork() duplicates the process, then the next fork() creates four.
- The final fork() creates eight processes because each of the four turns into two.
Zombie Processes
- Completed processes still with an entry in the process table to store its exit status for the parent process.
- Consume system resources, which mainly comprise process table entries, potentially leading to resource exhaustion.
- Terminate when parent processes read their exit status using wait() or when the parent process terminates, which then init() cleans them up.
Inter-Process Communication (IPC)
- Cooperating processes use interprocess communication mechanisms.
Shared Memory vs. Message Passing
- Shared memory: Processes read/write directly to a memory area, which also requires synchronization.
- Message Passing is processes sending and receiving messages through the kernel which is secure and easier to manage but has overhead.
OS Responsibilities in IPC
- Shared memory: OS manages creation, destruction, and synchronization of segments.
- Message passing: OS handles transmission, reception, message queues, synchronization, process blocking.
Message-Passing Methods
- Synchronous: Sender/receiver blocked until operation completes.
- Asynchronous: Process continues execution.
- Automatic Buffering: OS stores messages until receiver is ready.
- Explicit Buffering: Processes manage message storage.
- Send by Copy: Copies entire message ensuring data safety (slow).
- Send by Reference: Passes reference - faster, but risk of data issues.
- Fixed-Size Messages: Simplify buffer management - can waste space or limit message size.
- Variable-Size Messages: More flexible, requires more complex management.
Threads: User-Level vs. Kernel-Supported
- User-Level Threads:
- Managed by a library at the user level, not visible to the kernel.
- Faster to create and manage because they don't involve system calls.
- Kernel-Supported Threads:
- Managed directly by the OS, scheduled separately.
- Can utilize multiple processors effectively for true parallelism.
Threads: Advantages and Disadvantages
- User-Level Threads:
- Advantages: Less overhead, faster context switches.
- Disadvantages: Lack true concurrency on multiprocessor systems, blocking operations can block the whole process.
- Kernel-Supported Threads: -Advantages: Better CPU utilization, true concurrency. -Disadvantages: Higher overhead due to system calls for operations and context switches involving the kernel.
Critical Section
- Ensures only one process works at a time within a code segment.
- The critical-section problem makes it so no other process is allowed to execute in their critical section when one process is already in it.
Requirements for Critical-Section Problem Solutions
- Mutual Exclusion: Ensures only one process accesses a shared resource at a time, therefore, no others can execute in their critical sections.
- Progress: If no process is in its critical section, only processes not their remainder section should participate in deciding which enters next.
- Bounded Waiting: Sets a limit on a process's wait time to enter; setting the number of other processes that can enter their section before the request is granted.
Atomic Instructions
- Defined as instructions that execute completely without interruption.
- Without atomic execution, mutual exclusion can be violated, which compromises synchronized operations.
Three Requirements for the Critical Section
- Mutual exclusion
- Progress condition
- Bound waiting
Spinlocks
- Synchronization mechanism where a thread checks a lock in a loop until available instead of blocking.
- Spinlocks implemented using atomic instructions lead to fast locking/unlocking.
- These have low overhead for critical sections.
- Spinlocks can waste CPU cycles in high contention or single-core scenarios.
Use of Spinlocks
- Solaris, Linux, and Windows 2000 utilize it on multi-processor systems.
Semaphore Code Example
Assume Initially
Q=1
S1
wait(Q)
S2
signal(Q)
S3
Pthread Functions
- *int pthread_mutex_lock(pthread_mutex_t mutex);
- Used before accessing a shared variable to lock it.
- *int pthread_mutex_unlock(pthread_mutex_t mutex);
- Used after finishing with a shared variable to unlock it.
Scheduling Types
- Short-term (CPU scheduler): Selects from memory and allocates the CPU.
- Medium-term: For swapping in time-sharing systems.
- Long-term (job scheduler): Determines which jobs are brought to memory.
I/O-Bound vs. CPU-Bound
- I/O-bound programs: Small computation before I/O, do not use the entire CPU quantum.
- CPU-bound programs: Fully use CPU without blocking I/O.
- Prioritizing and allowing I/O-bound programs to go first means better resource use.
Process State Transitions
- Waiting -> Running is illegal, must fire be placed in the ready queue before selection.
- Running -> Waiting is legal if requesting a resource.
- Ready -> Waiting is illegal, can only transition from Running.
Optimizing Response Time
- Optimizing response time speeds operations, optimizing CPU usage.
Result of Shortest Job First and Priority-Based
- Can result in starvation, denying CPU time to lower-priority and those with long process times.
Round Robin Algorithm with Two PCB Pointers Effect
- The process would run twice as many times.
Round Robin Algorithm with Two PCB Pointers Advantages
- Prioritization of important processes.
- Prevention of lower-priority processes from being starved.
- It does not require changes to the scheduling algorithm.
Round Robin Algorithm with Two PCB Pointers Disadvantages
- Context switching impact increases.
- Removing processes becomes significantly harder.
Altering the basic Round Robin Algorithm Without Duplicates
- Increase the quantums.
CPU utilization for Round-Robin When Time Quantum is 1 millisecond
- Scheduler incurs 0.1ms of context-switching.
- CPU utilization is about 91%.
CPU utilization for Round-Robin When Time Quantum is 10 millisecond
- CPU utilization is 94% because I/O Tasks incur context switch after 1 millisecond.
Formulas for computing Time Bursts for Scheduling
- ( 8 + (12 - 0.4) + (13 - 1)) / 3 = 10.53
- ( 8 + (9 - 1) + (13 – 0.4)) / 3 = 9.53
- ((2 - 1) + ( 6 – 0.4 ) + ( 14 - 0)) / 3 = 6.87
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.