0
0
Operating Systemsknowledge~20 mins

Thread creation and management in Operating Systems - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Thread Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Thread Creation Methods

Which of the following is not a common method to create a thread in an operating system?

ACreating a thread by specifying a function to execute
BUsing a thread library function like pthread_create()
CCloning an existing process with fork()
DUsing a thread class constructor in high-level languages
Attempts:
2 left
💡 Hint

Think about the difference between processes and threads.

📋 Factual
intermediate
2:00remaining
Thread Lifecycle States

Which of the following is not a typical state in a thread's lifecycle?

AZombie
BSleeping
CRunning
DWaiting
Attempts:
2 left
💡 Hint

Consider which states apply to threads versus processes.

🔍 Analysis
advanced
2:00remaining
Effect of Thread Priority on Scheduling

Consider a system where threads have priorities. If a high-priority thread is ready to run, what is the most likely behavior of the scheduler?

AIt will always run the high-priority thread immediately, preempting any running lower-priority thread.
BIt will wait for the current thread to finish before running the high-priority thread.
CIt will run threads in the order they were created, ignoring priority.
DIt will randomly select any thread to run regardless of priority.
Attempts:
2 left
💡 Hint

Think about preemptive scheduling and priority.

Comparison
advanced
2:00remaining
User-Level vs Kernel-Level Threads

Which statement correctly compares user-level threads and kernel-level threads?

AKernel-level threads cannot run in parallel on multiple processors.
BKernel-level threads can be scheduled independently by the OS, but user-level threads cannot.
CUser-level threads require more overhead to switch than kernel-level threads.
DUser-level threads are managed by the kernel, while kernel-level threads are managed by user libraries.
Attempts:
2 left
💡 Hint

Consider who manages the threads and how scheduling works.

Reasoning
expert
2:00remaining
Deadlock Scenario in Thread Management

Given two threads T1 and T2 and two resources R1 and R2, which scenario can cause a deadlock?

Assume each thread locks one resource and waits for the other.

AT1 and T2 both wait for R1 without locking any resource.
BT1 locks R1, then releases it before locking R2; T2 locks R2 and then locks R1.
CT1 locks R1 and R2 sequentially without waiting; T2 waits for R1 only.
DT1 locks R1, T2 locks R2, then T1 waits for R2 and T2 waits for R1.
Attempts:
2 left
💡 Hint

Deadlock happens when threads wait on each other holding resources.