review question 3.pdf
Document Details
Uploaded by RaptQuasimodo
Tags
Full Transcript
Keep the ques*ons and answers exactly as they are. What is a thread in compu*ng? a) A sequence of stored data. b) A unit for alloca*ng system memory. c) A basic unit of CPU u*liza*on. d) A type of computer process. Correct Answer: c) A basic unit of CPU u*liza*on. Explana*on: Threads are the smalles...
Keep the ques*ons and answers exactly as they are. What is a thread in compu*ng? a) A sequence of stored data. b) A unit for alloca*ng system memory. c) A basic unit of CPU u*liza*on. d) A type of computer process. Correct Answer: c) A basic unit of CPU u*liza*on. Explana*on: Threads are the smallest sequence of programmed instruc*ons that can be managed independently by a scheduler. What is a benefit of mul*-threading in an opera*ng system? a) Increases the complexity of a program. b) Slows down the execu*on of tasks. c) Allows a process to perform more than one task at a *me. d) Requires more memory than single-threading. Correct Answer: c) Allows a process to perform more than one task at a *me. Explana*on: Mul*-threading enables a program to be more efficient by doing mul*ple tasks simultaneously, like upda*ng a display while fetching data. What is the difference between concurrency and parallelism? a) Concurrency involves task order, parallelism requires tasks to be the same. b) Concurrency is task coordina*on, parallelism is doing tasks at the same *me. c) Concurrency is for single-core CPUs, parallelism is for mul*-core CPUs only. d) There is no difference; they are the same. Correct Answer: b) Concurrency is task coordina*on, parallelism is doing tasks at the same *me. Explana*on: Concurrency is about dealing with many things at once (like mul*tasking) and parallelism is about doing many things at once. In a mul*-threading model, what does the one-to-one mapping mean? a) One user-level thread maps to one kernel thread. b) One thread is responsible for one task only. c) One thread runs at a *me. d) One program uses one thread. Correct Answer: a) One user-level thread maps to one kernel thread. Explana*on: In the one-to-one model, each thread created by a user in a program corresponds to a single thread at the kernel level. What is a thread pool? a) A collec*on of data for threads to process. b) A type of memory alloca*on for threads. c) A group of threads pre-created and wai*ng for tasks. d) A debugging tool for thread management. Correct Answer: c) A group of threads pre-created and wai*ng for tasks. Explana*on: Thread pools are a way to manage mul*ple threads by having a ready pool of worker threads that can be used to perform tasks. How is thread cancella*on achieved in pthreads? a) By sending a signal to the opera*ng system. b) By seVng the thread's state to 'finished'. c) By calling pthread_cancel(). d) By dealloca*ng the thread's memory. Correct Answer: c) By calling pthread_cancel(). Explana*on: To cancel a thread in the pthreads library, the pthread_cancel() func*on is used, which requests cancella*on of another thread. What does a thread pool in a mul*-threaded applica*on do? a) Limits the number of threads to the maximum number of CPU cores. b) Creates a new thread for each task as it comes. c) Provides a set of ini*alized threads that stand by to handle tasks. d) Assigns one thread per CPU core permanently. Correct Answer: c) Provides a set of ini*alized threads that stand by to handle tasks. Explana*on: A thread pool maintains a number of dormant threads that are ready to execute tasks, improving efficiency by avoiding the overhead of crea*ng and destroying threads for each task. What is the main difference between user threads and kernel threads? a) User threads are created by the opera*ng system, kernel threads by the applica*on. b) User threads are managed by the applica*on, kernel threads by the OS. c) Kernel threads can execute system calls, user threads cannot. d) User threads are faster than kernel threads. Correct Answer: b) User threads are managed by the applica*on, kernel threads by the OS. Explana*on: User threads are managed by a user-level library, making them faster and more efficient to create and manage than kernel threads, which are managed by the opera*ng system. What is the many-to-many threading model? a) Maps many user-level threads to one kernel-level thread. b) Maps each user-level thread to a separate kernel-level thread. c) Allows many user-level threads to be mapped to many kernel threads. d) Does not allow mul*ple threads at the user or kernel level. Correct Answer: c) Allows many user-level threads to be mapped to many kernel threads. Explana*on: The many-to-many model can map mul*ple user-level threads to the same or a smaller number of kernel threads, allowing for efficient concurrency without overwhelming the system with too many kernel threads. How is concurrent execu*on achieved on a single-core system? a) By running all threads at exactly the same *me. b) Through parallel execu*on of threads. c) By quickly switching between tasks to give the appearance of simultaneous execu*on. d) Single-core systems cannot achieve concurrent execu*on. Correct Answer: c) By quickly switching between tasks to give the appearance of simultaneous execu*on. Explana*on: On a single-core system, concurrency is simulated by *me-slicing, where the CPU rapidly switches between different tasks, giving the illusion of them running in parallel.