Explore core concepts of green threads, their benefits, limitations, and the basics of user-level scheduling. This quiz is designed to assess essential knowledge for those interested in lightweight threading models and efficient concurrency in programming.
Which statement best describes green threads in the context of computer programming?
Explanation: Green threads are scheduled and managed in user space, not by the OS kernel, making them user-level threads. Kernel threads are managed by the operating system, not a user-level library. Green threads are not related to hardware units or memory allocation methods, so those options do not accurately describe them.
What is a key difference between green threads and kernel threads?
Explanation: Green threads, being managed in user space, are usually limited to running on one core regardless of hardware because the OS sees them as a single process. Kernel threads, on the other hand, can run on multiple cores. Green threads do not require administrative privileges, are not inherently faster at machine instructions, and are not hardware-based, making the other options incorrect.
If a green thread performs a blocking I/O operation, what typically happens to the other green threads in that process?
Explanation: Because the operating system sees the process as a single thread, if one green thread blocks on I/O, all green threads in that process are blocked. Green threads are not scheduled separately by the kernel, and blocking does not only affect the current thread. Green threads do not automatically use non-blocking I/O.
What does user-level scheduling refer to in the context of green threads?
Explanation: With user-level scheduling, the green thread library decides when and how threads run, instead of the operating system. The operating system does not schedule green threads individually, users do not choose hardware for green threads directly, and scheduling does not depend solely on keyboard input.
In a green-threaded system using cooperative multitasking, what is required for one thread to allow another to run?
Explanation: In cooperative multitasking, threads must yield control themselves for others to run. The OS does not automatically interrupt or switch green threads, and automatic switching based on timer events requires preemptive scheduling, which is not the case here.
Which is a commonly cited benefit of using green threads over kernel threads?
Explanation: Green threads typically switch contexts faster because it happens at the user level without OS involvement. Security is not inherently better, bugs can still occur in green threads, and they are not managed by the operating system, so those distractors are incorrect.
Why are green threads often considered more portable across operating systems?
Explanation: Green threads can be implemented without OS-specific thread APIs, making them portable. They do not depend on proprietary hardware or specific kernel features, and they are not limited to older operating systems, which makes the other options incorrect.
What is a major limitation of green threads on multi-core systems?
Explanation: Green threads typically run on a single core because the operating system sees them as one thread per process. They do not automatically distribute across cores, usually use less memory, and do not require kernel oversight, making the other options less appropriate.
Which scheduling algorithm is often used by green thread libraries for managing threads?
Explanation: Round-robin is a simple and common scheduling method for green thread libraries, allowing each thread a fair chance to run. Priority-based scheduling is more typical at the kernel level, LRU is for cache management, and Weighted Fair Queueing applies to networking, so the other answers do not fit.
How does user-level context switching in green threads commonly compare in speed to kernel-level thread switching?
Explanation: Since user-level context switching does not trigger operating system kernel code, it is usually faster than kernel thread context switching. Contrary to some distractors, it does not require extra system calls, recompiling the kernel, and it absolutely matters for performance.