📝 Multicore programming in operating system (33 MCQs)
Multicore Processor Architecture and Parallel Execution
Multicore programming develops applications that divide work among multiple processing cores within a processor or computer system. Each core can execute an instruction stream independently, allowing separate threads to run simultaneously. Operating system process and thread schedulers distribute runnable work across available cores, while memory management and synchronisation facilities coordinate access to shared data and hardware resources.
Why Single-Core Execution Limits Parallel Workloads
A single processing core can execute only one instruction stream at a time, even when a program contains multiple independent tasks. Increasing clock frequency alone faces power and thermal limitations. Multicore systems provide additional execution resources, but applications must expose independent work and coordinate shared state to benefit from simultaneous processing.
Thread Distribution and Shared-Memory Coordination
An application divides work into threads that can execute independently. The operating system scheduler assigns runnable threads to available cores, while each core maintains its own execution state. Threads may access shared memory, requiring mutexes, atomic operations, or other synchronisation mechanisms. Cache-coherence hardware helps maintain memory consistency between processor caches according to the architecture.
Dividing Image Processing Across Four CPU Cores
Suppose an image contains 4,000 rows and must undergo the same independent filter operation on every row. Four worker threads can each process approximately 1,000 rows. If work is evenly distributed and memory access does not become a bottleneck, the operations can execute simultaneously, reducing elapsed processing time compared with a single-core execution.
Speedup, Core Utilisation, and Parallel Workload Limits
Multicore programming improves throughput for parallel workloads in scientific computing, rendering, databases, and media processing. However, sequential instructions, lock contention, memory bandwidth, and uneven workloads limit speedup. Amdahl's law estimates the maximum speedup for a fixed workload: with sequential fraction S and N cores, speedup is limited to 1 divided by S plus the parallel fraction divided by N.
Misconceptions About Multicore Execution
'Four cores guarantee four times the performance' is incorrect because sequential work and contention restrict speedup. 'The operating system automatically makes every program parallel' is incorrect because the application must expose suitable concurrent work. 'Separate cores never share hardware resources' is incorrect because cores may compete for memory bandwidth, caches, and other shared resources.
Exam Focus: Core Allocation and Parallel Speedup
Distinguish concurrency from simultaneous execution and explain how the scheduler distributes threads across cores. Practise applying Amdahl's law and identifying sequential and parallel portions of a workload. Questions may examine core utilisation, cache coherence, load balancing, synchronisation, and reasons why adding processors produces less than proportional performance gains.
Key Terms of Multicore Programming
- Core - Independent processor execution unit.
- Parallelism - Simultaneous execution of tasks.
- Load balancing - Distributing work among processors.
- Amdahl's law - Formula limiting parallel speedup.
- Cache coherence - Maintaining consistent cached data.
- Atomic operation - Indivisible shared-state operation.
📝 All Multicore programming in operating system MCQs
Q1. Which hardware arrangement enables a multicore processor to execute independent instruction streams at the same instant?
📖 Explanation: A multicore chip contains multiple independent processing cores. Each core has its own execution resources and can run a separate instruction stream, allowing simultaneous execution rather than relying only on time-sliced switching.
Q2. A single-core computer alternates between two runnable threads, while a two-core computer runs one thread on each core. Which statement distinguishes these cases?
📖 Explanation: Concurrency means activities make progress over overlapping periods, even when one processor alternates between them. Parallelism is stricter: instructions from different execution paths run at the same instant on separate cores.
Q3. A program contains one ordinary software thread and is run on an eight-core processor. Why will that thread not normally use all eight cores simultaneously?
📖 Explanation: Adding cores increases available hardware execution capacity, but it does not automatically divide one instruction stream into independent parts. A single software thread normally runs on one core at a time.
Q4. A video-encoding application has four independent worker threads and a processor with four available cores. What can the hardware provide when all workers are runnable?
📖 Explanation: When four independent threads are runnable and four cores are available, the scheduler can place one thread on each core. Their instructions can then execute simultaneously, subject to resource availability and scheduling decisions.
Q5. A processor has multiple cores, and each core can execute a different instruction stream on different data. Which architecture description best fits this organization?
📖 Explanation: MIMD systems allow multiple processing units to execute different instruction streams on different data. This matches multicore processors running separate software threads, whereas SIMD applies one instruction across multiple data elements.
Q6. A numerical application applies the same addition operation to many independent array elements. Which hardware capability can process several elements with one instruction on a core?
📖 Explanation: SIMD vector instructions apply one operation to multiple data elements in a single instruction. A core can therefore process several array values together, complementing the parallel execution available across multiple cores.
Q7. A multithreaded application runs on a shared-memory multicore computer. Which statement describes the programming environment most accurately?
📖 Explanation: In a shared-memory multicore system, threads can access the same process address space even when different cores execute them. The common memory model simplifies communication, although it does not by itself coordinate conflicting updates.
Q8. A workload performs the same mathematical operation on millions of independent pixels. Why might a GPU be considered alongside a general-purpose multicore CPU?
📖 Explanation: GPUs contain many execution elements designed to process large amounts of parallel data. They can accelerate workloads such as image transformations, although irregular control-heavy tasks may suit general-purpose CPU cores better.
Q9. A batch program contains 20 independent jobs, each requiring 4 ms of CPU time. Five cores are available, and scheduling overhead is negligible. What is the ideal completion time?
📖 Explanation: Five cores can process five jobs in each wave. Twenty jobs require four waves, and each wave takes 4 ms, so the ideal completion time is ms.
Q10. A parallel program completes a workload in 18 seconds on one core and 6 seconds on three cores. What speedup does the three-core execution achieve?
📖 Explanation: Speedup is the single-core execution time divided by the parallel execution time. Here, , so the three-core run is three times as fast overall for the measured workload.
Q11. A four-core application achieves a measured speedup of 3.2 relative to one core. What is its parallel efficiency?
📖 Explanation: Parallel efficiency is speedup divided by the number of cores used. The calculation is , which corresponds to 80 percent efficiency for the measured parallel execution in this configuration.
Q12. A student predicts that a program with 20 percent serial work and 80 percent parallel work will become four times faster on four cores. Using Amdahl reasoning, what is the correct ideal speedup?
📖 Explanation: The flawed step is assuming the entire program is parallel. The correct calculation is , because the serial portion remains unchanged under the stated ideal conditions.
Q13. A multicore computer has six runnable software threads and four available cores. Which statement best describes the operating system scheduler role?
📖 Explanation: The scheduler selects runnable threads and maps them onto available processing cores. With more runnable threads than cores, some threads must wait or be time-sliced; hardware cannot execute all six simultaneously on four cores.
Q14. A developer is adapting a sequential simulation for a multicore processor. Which first step is most useful for exposing parallel execution?
📖 Explanation: Parallel execution requires independent or suitably coordinated work that can be assigned to different cores. Identifying such work is a necessary design step; adding cores alone does not create parallel tasks inside sequential code.
Q15. A rendering program has 12 independent frames to process. Each frame requires 5 ms of CPU time, and three cores are available. Assuming perfect distribution and no overhead, how long will the frames take?
📖 Explanation: Three cores can process three frames during each 5 ms wave. Twelve frames require waves, so the ideal elapsed time is ms.
Q16. A benchmark reports core count and speedup as follows: (1, 1.0) ; (2, 1.8) ; (4, 3.1) ; (6, 4.0) ; (8, 4.5). Which trend is most clearly shown?
📖 Explanation: The measured speedup rises from 1.0 to 4.5, but gains become smaller as more cores are added. This is diminishing return rather than linear scaling, often because some work cannot execute in parallel.
Q17. A multicore benchmark reports core count and throughput in jobs per second: (1, 100) ; (2, 190) ; (3, 270) ; (4, 340) ; (5, 345). At which point does the data first show a clear approach to saturation?
📖 Explanation: Throughput increases by 70 jobs per second from three to four cores, but only five from four to five. The sharp reduction in marginal gain indicates that the workload is approaching its throughput limit.
Q18. A student claims that four runnable threads on a two-core processor can all execute instructions simultaneously because they belong to one multithreaded process. What is the correction?
📖 Explanation: The flawed step is confusing the number of threads with the number of physical execution cores. With two cores, at most two software threads execute simultaneously; the remaining runnable threads await scheduling.
Q19. A developer runs an unchanged single-threaded program on a processor with twice as many cores and expects its execution time to be halved. Which assumption is incorrect?
📖 Explanation: The incorrect assumption is that extra cores automatically parallelize serial code. Without dividing the workload into concurrent execution paths, the single thread remains bound to one core and gains no direct multicore speedup.
Q20. An image-processing program divides an array into four disjoint regions and uses four cores. Each core also applies a vector instruction to several values in its assigned region. Which combination is being used?
📖 Explanation: The regions can run simultaneously on separate cores, while each core uses a vector instruction on several values in its own region. This combines multicore execution with SIMD-level parallelism within a core.
Q21. Two worker threads run on separate cores and read different portions of one shared array. Which design choice lets them use the same array without copying it into separate process address spaces?
📖 Explanation: Threads in one process share the same virtual address space, so each can access its assigned array region directly. Separate processes would generally need an explicit sharing or data-transfer arrangement.
Q22. A student classifies a system as SIMD because four cores execute four different programs on four different data sets. Which correction is accurate?
📖 Explanation: The classification is wrong because SIMD applies the same instruction across multiple data elements. Different cores running different programs on different data sets match the MIMD execution model on a multicore processor.
Q23. A mobile processor combines high-performance cores with power-efficient cores. Why is this heterogeneous multicore design useful?
📖 Explanation: Heterogeneous processors provide cores with different performance and energy characteristics. The system can place demanding work on faster cores and less urgent work on efficient cores, balancing responsiveness with energy consumption.
Q24. A graphics workload applies the same color adjustment to 10 million independent pixels. Which execution platform is most likely to offer high throughput for this workload?
📖 Explanation: The pixel operations are numerous and largely independent, making them suitable for a throughput-oriented GPU. Such processors execute many similar operations in parallel, while a general-purpose CPU remains useful for control-heavy work.
Q25. A parallel program has a serial fraction of 10 percent and a parallel fraction of 90 percent. According to Amdahl reasoning, what is the maximum possible speedup as the number of cores approaches infinity?
📖 Explanation: As core count approaches infinity, the parallel portion takes negligible time, but the serial 10 percent remains. The upper bound is therefore , regardless of additional cores under these assumptions.
Q26. A developer uses an OpenMP parallel-for construct on a loop whose iterations are independent. What is the intended multicore effect?
📖 Explanation: An OpenMP parallel-for construct expresses that independent loop iterations may execute concurrently. The compiler and runtime create or use a thread team and distribute iterations, subject to loop dependencies and runtime configuration.
Q27. A processor exposes four logical CPUs through simultaneous multithreading, but those logical CPUs belong to two physical cores. A student assumes this is identical to having four independent physical cores. What is the error?
📖 Explanation: The assumption ignores shared physical resources. Simultaneous multithreading exposes multiple hardware-thread contexts per core, but those contexts may compete for execution units and caches rather than behaving like separate physical cores.
Q28. A program has 90 percent parallel work and 10 percent serial work. What ideal speedup should be expected on eight cores, ignoring overhead?
📖 Explanation: Amdahl calculation is , which is approximately 4.71. The serial fraction limits the gain even when eight cores are available without extra overhead in this idealized eight-core case.
Q29. A developer says that a multicore processor automatically turns a conventional sequential loop into parallel work whenever several cores are idle. Which statement best corrects this claim?
📖 Explanation: Idle cores do not reveal which iterations are independent or how results should be combined. The program or its compiler must expose safe parallel work before the scheduler can distribute it across cores.
Q30. A server has four cores and uses one thread per core for a workload with independent requests. A request arrives while all four threads are busy. What can the operating system do?
📖 Explanation: When every core is occupied by a running worker, another request cannot begin immediate CPU execution on those cores. It can wait in a queue until a worker or core becomes available.
Q31. Which statement best describes the relationship between multicore execution and higher clock frequency?
📖 Explanation: Multiple cores increase the number of instruction streams that may execute simultaneously. Clock frequency affects how quickly each core advances, so adding cores and raising frequency are distinct performance approaches.
Q32. A simulation has a serial setup stage taking 2 seconds followed by four independent tasks taking 8 seconds each. With four cores, all tasks run simultaneously and setup occurs first. Ignoring overhead, what is the total elapsed time?
📖 Explanation: The serial setup requires 2 seconds. The four independent 8-second tasks then execute together on four cores, adding 8 seconds, so total elapsed time is seconds.
Q33. A data-analysis program processes 800 independent records, each requiring 0.5 ms of CPU time. Four cores divide the records evenly, then a serial merge takes 10 ms. Ignoring overhead, what is the total time?
📖 Explanation: Each core handles 200 records, requiring ms. The serial merge adds 10 ms, so total elapsed time is ms under ideal balancing.