1. - 30 % Answer these questions: a) On a single-CPU system, under what circumst
ID: 3850328 • Letter: 1
Question
1. - 30 %
Answer these questions:
a) On a single-CPU system, under what circumstances does a multithreaded program using
kernel threads provide better performance (such as faster execution time) compared to a singlethreaded
solution (that does not use asynchronous or event-based programming) ?
b) Consider the Dining Philosophers implementation with a monitor. Explain why does the putdown()
operation call the test() operation twice ?
c) Contrast synchronization with spinlocks in single-CPU vs. multiple-CPU computers.
Explanation / Answer
A) Multi threaded program on a single CPU can provide faster execution if a CPU can have multiple cores, then each thread can run on separate core by means it will run like parallel. so it will provide faster execution.
C) SPin Lock meaning is that a thread will try to obtain the resource untill it gets that , meaning that thread will be continuolsy executing the process into CPU. so making CPU busy , so in case of Single CPU systems it doesn't make sense because untill the thread gets its resource it will make other threads to stop working because current thread is busy in loop by occupying CPU.
IN case of multiple CPU computers it makes sense to use spin lock because sometimes if it takes very less time to obtain resource then we should wait in spin lock and obtain the resource rather than performing the context switch ( because context switch also takes lots of time ) . so in multi cpu we can use spin lock it will provide better performance , but in single cpu performance gets degraded.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.