OSC Flashcards
Can a user program write to a specific location in physical memory?
No, because of significant risk to system security and hardware protection.
Can a user find out where a variable lives in physical memory
No, modern OS and programming languages use virtual memory addresses as an abstraction layer.
How can a system call allow a user process to run on kernel space code?
A system call can allow a user process to run on kernel space code by acting as a bridge, when a user needs to perform a privileged task or access resources managed by the OS.
Why use C for implementation
Adaptability, Functionality, Efficiency, Portability and also predictability.
What would be the pros/cons of a small kernel with limited collection of systems calls?
the cons would be limited access to privileged resources or to perform a privileged task, development constraint and lack of functionality, pros it would reduce complexity, resource-efficient as less systems calls, efficiency less overheads
What are the 5 processes states
New = The process is being created and initialized by the operating system., ready = waiting for cpu to be available, running = executed by the cpu, blocked = waiting for I/O or an event, terminated = no longer executable
Why might you run fork() without running subsequent exec?
If there is a need for parallel execution of different tasks.
do you always need to call exit to end a process?
No, when reaching the end of its execution it’s terminated by the OS.
Why does a PCB contain data about register contents?
For 3 main reasons, interrupt handling when an interrupt occurs the state of the process needs to be saved, so it later can be resumed. To make decisions about process scheduling. Because of context switching the OS needs to restore the state of each process.
Why might it be useful to retain a PCB for a terminated process?
Parental Notification (Allowing the parent to know if it has finished) , Process accounting (tracking metrics, etc..)
Why is Round robin is said to favour CPU-bound processes over I/O bound processes?
because round-robin has a fixed time slice and usually cpu-bound processes need the entire time or more to complete their task, where as I/O bound-processes might release their CPU usage because of spending time waiting for an event.
Using the non-preemptive shortest job first scheduler, does the shortest job run on the CPU until is completed?
Non-preemptive means no interruption by the scheduler until it finishes its execution or enters a waiting state.
What is a non-preemptive scheduler?
Processes are only interrupted voluntarily (e.g. I/O waiting or system calls)
What is a preemptive scheduler?
Processes can be interrupted forcefully or voluntarily, typically driven from interrupts from a system clock (regular intervals).
What is defined as average response time? and
Average of the time taken for all processes to start
What is defined as turn around time?
Average of the time taken for all
processes to finish
Explain First Come First Served scheduling algorithms?
Non-preemptive scheduling, operates as a strict queue, schedules the processes in the same ordered they were added to the queue, favour long processes over short ones, could compromise resource utilisation
Explain Shortest job first
Non-Preemptive scheduling, operates as a shortest processing time using a known estimate of processing. Processing times have to be known before hand, starvation, predictability might be at compromised.
Explain Round Robin
Round robin is an preemptive version of FCFS that forces periodic context switches at periodic intervals or time slices, processes run in the ordered added to the queue, advantages are improved response time, increased context switching and thus overhead, favours CPU-BOUND processes over I/O bound processes.
Explain priority queues scheduling algorithm
A preemptive algorithm that schedules process by priority, round robin is used if the same priority
What is the main difference between threads and processes?
Threads share memory and processes don’t this brings a few things to consideration such as lower resource overhead, however threads are much less fault-tolerant because of having to being very careful with synchronization.
Why use threads?
Processes will often contain multiple blocking tasks (interrupts) certain activities should be carried in parallel/concurrently. Multiple related activities apply to the same resources so these resources should be shared/accessible
How is user thread managed in the user space?
(creating, destroying, scheduling, thread control block manipulation) is all done using a user library
Advantages of using USER threads? and disadvantages?
No context switch required since threads are in user space. Full control over the thread scheduler. OS independent. No true parallelism, No clock-interrupts threads are non-preemptive. Page faults result in blocking the process.
Advantages and Disadvantages of Kernel threads
True Parallelism
No run-time system needed
It will have frequent context switches resulting in lower performance
(WINDOWS AND LINUX TAKE THIS APPROACH.)
If the threads in a process share the same memory, why do they have independent stacks?
Because it provides a level of isolation and control which is essential, because each thread need its own function call information, independent stack ensure each thread can manage its own functions calls and also errors if encounters one.
Is it always necessary to call pthread_exit when ending a thread?
No, it is not always necessary to call pthread_exit when ending a thread. The termination of a thread can occur in different ways such as return 0 in the main function, return null in the function the thread is called.
What is the minimum number of threads a process can have?
One, which is the main thread created and represents the primary flow of control within the program.
Can user threads make good use of concurrent hardware?
User threads can make use of concurrent hardware to some extent, but their ability to fully exploit the benefits of multiple processor cores is limited compared to kernel threads.
Why is it efficient to schedule threads that communicate with each other at the same time?
Because then they will share the same memory and access the same resources at the same time that implies with good synchronisation it will be better to have them executing at the same time. Faster Communication, can also lead to overall better throughput
What does throughput mean?
In essence, throughput is an indicator of the system’s efficiency in executing workloads,
How does the CFS avoid starvation?
CFS uses time slicing so that every process gets a fair share of CPU time, it also dynamically adjusts the priority of processes based on their CPU usage history
If a thread is interrupted by I/O where is the process state saved?
in the PCB
Why is the outcome of programs might be unpredictable
the outcome of executing might depend on the order in which code gets to run in the CPU. Sharing data can also be inconsistent and we can be interrupted part way through doing something
What is a race condition?
A race condition typically occurs when multiple threads access shared data and the result is dependent on the order in which the instructions are ran.
What is meant by critical section?
A critical section is a section of code that can only be executed by one thread at a time.
What is meant by mutual exclusion?
Mutual exclusion, is a concept involving techniques or mechanisms to ensure that only one thread or process at a time can access the critical section. (locks?)