Challenge your understanding of operating system concurrency, focusing on the core concepts of processes, threads, context switching, and synchronization. This quiz is designed to help learners review key concurrency principles commonly covered in introductory operating systems courses.
Which statement best describes a primary difference between a process and a thread in operating systems?
Explanation: Processes are independent execution units with separate memory, but threads within the same process share the same memory region. Threads do not always run faster than processes, as speed depends on many factors, making option B incorrect. Processes can communicate with each other using inter-process communication, so option C is false. Threads are schedulable entities, so option D is incorrect.
What does concurrency mean in the context of operating systems?
Explanation: Concurrency allows several tasks or threads to be in progress at overlapping periods, even if not simultaneously on a single-core CPU. Option A is sequential execution, option B is not concurrency but serial execution, and option D confuses the types of programs with the concept itself.
If a word processor launches a spell-checker in a separate process, how are their memory spaces related?
Explanation: Separate processes each have their own memory, keeping their data isolated unless specifically set up for sharing. Automatic sharing does not occur, so option B is incorrect. The spell-checker can access files if allowed, so option C is wrong. Processes do not merge, making option D incorrect.
In a web browser, when each tab runs as a separate thread within the same process, what does this allow them to share?
Explanation: Threads within a process can access the same global variables and heap memory, making shared data possible. Option B is wrong since threads do not have completely separate memory. Input devices are not restricted at the thread level, disqualifying option C, and option D is too narrow a view of sharing.
What best describes a context switch in an operating system?
Explanation: A context switch involves the operating system temporarily stopping one process or thread and resuming another, saving and restoring their state. It does not merge threads, copy files, or occur only at startup, making options B, C, and D incorrect.
Which of the following is commonly used to prevent race conditions when multiple threads access shared data?
Explanation: A mutex lock is designed to coordinate access to shared resources, preventing race conditions. Network cables and firewall rules relate to connectivity and security, not synchronization. Read-only memory cannot be used by threads to coordinate changes because it cannot be modified.
What is a key advantage of using threads over creating multiple processes for concurrency?
Explanation: Threads are lightweight and share memory, making switching between them relatively fast. They do not run on separate machines by definition, making option B incorrect. Both threads and processes can access hardware if programmed, so option C is wrong. Option D is false as processes do terminate.
Which statement best explains the critical section problem in concurrent programming?
Explanation: A critical section is part of code where shared resources are accessed, and it must be protected to avoid simultaneous access. Deleting system files, increasing CPU cores, and compressing code are not related to the critical section problem.
In a situation with two threads each waiting for a resource held by the other, what is this situation called?
Explanation: Deadlock occurs when two or more threads are waiting indefinitely for resources locked by each other, halting further progress. A pipeline refers to sequential execution stages, buffer overflow is an excess data issue, and scheduler jump is not a standard concurrency term.
What does preemptive scheduling allow the operating system to do with threads or processes?
Explanation: Preemptive scheduling lets the OS interrupt running tasks to ensure fair CPU use among processes or threads. It does not prevent threading, guarantee sort order for process execution, or randomly allocate memory, making the other options inaccurate.