Define “forking”. How many processes are created as a result of a fork()
Define argc and argv[]
Define time quantum
In multitasking operating systems, a time quantum (or time slice) is a predefined amount of CPU time allocated to a process. When a process is in the running state and its time quantum expires, the OS preempts (interrupts) it and gives the CPU to another ready process. This ensures fair sharing of CPU resources among multiple running processes.
What system call is used to start a new thread of execution?
Define context switching
Context switching is the process of saving the state of the currently running process (CPU registers, program counter, etc.) and loading the state of a new process or thread that will be scheduled to run on the CPU next. This allows the OS to efficiently switch between multiple processes or threads, giving the illusion of multitasking.
Define CPU bound process and compare/contrast it with I/O bound processes
What are the difference states of a process?
What does execv() do?
What does it mean for an application to be multithreaded?
What do the following function(s) do: pthread_yield()
pthread_yield() (deprecated): Causes the calling thread to yield the processor to another thread.
This function is considered deprecated in many systems. It tells the thread to voluntarily relinquish the CPU and allow another thread a chance to run. However, modern OS scheduling algorithms usually make this unnecessary.
What do the following function(s) do: pthread_create()
pthread_create(): Creates a new thread of execution.
This function creates a new thread of execution within a process. It takes arguments specifying the thread’s function, arguments to that function, and attributes for the thread (e.g., stack size).
What do the following function(s) do: pthread_join()
pthread_join(): Waits for a specific thread to terminate.
This function allows a thread (usually the main thread) to wait for another thread to finish execution. It takes the target thread’s ID and optionally a pointer to retrieve the value returned by the exiting thread with pthread_exit().
What do the following function(s) do: pthread_exit()
pthread_exit(): Terminates the calling thread and returns a value
This function allows a thread to terminate its execution and optionally return a value to the thread that joined it using pthread_join().
What is a race condition?
Describe the sleeping barber problem.
What are two problems with the sleeping barber?
Describe how spin locks work?What are the problems?
What are the problems with spin lock?
How does spin lock work?
List 3 items specific to processes
Items Specific to Processes:
- Process ID (PID)
- Address space
- Process control block (PCB)
List 3 items specific to threads
Items Specific to Threads:
- Thread ID (TID)
- Stack
- Register set
Processes vs Threads?
Processes:
- Each process has its own address space.
- Processes are heavyweight in terms of resource consumption.
- Communication between processes is typically slower.
Threads:
- Threads within the same process share the same address space.
- Threads are lighter in terms of resource consumption compared to processes.
- Communication between threads is faster as they share memory.
What are threads?
Threads are the entities within a process
scheduled for execution on the CPU.
How many programs does a process have? How many threads do each program has?
Every process has exactly one
program and every running program has at
least one thread of execution.