0
0
Intro to Computingfundamentals~20 mins

Process management (running programs) in Intro to Computing - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Process Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
trace
intermediate
2:00remaining
Trace the process states during program execution

Consider a program that is loaded into memory and executed by the CPU. Which sequence correctly shows the typical states a process goes through from start to finish?

A1,3,2,4,5
B1,2,3,4,5
C2,1,3,4,5
D1,2,4,3,5
Attempts:
2 left
💡 Hint

Think about the order: a process is created, waits to run, runs, may wait for input/output, then finishes.

🧠 Conceptual
intermediate
1:30remaining
Identify the role of the process scheduler

What is the main job of the process scheduler in an operating system?

ATo manage file storage on the hard drive
BTo load programs from disk into memory
CTo decide which process runs next on the CPU
DTo handle user input from keyboard and mouse
Attempts:
2 left
💡 Hint

Think about how the CPU chooses which program to run when multiple are ready.

Comparison
advanced
2:30remaining
Compare process and thread differences

Which of the following statements correctly distinguishes a process from a thread?

AA process has its own memory space; threads share memory within the same process
BThreads have separate memory spaces; processes share memory
CProcesses run only one at a time; threads run simultaneously
DThreads are independent programs; processes are parts of a program
Attempts:
2 left
💡 Hint

Consider how memory is allocated and shared between processes and threads.

identification
advanced
2:00remaining
Identify the cause of a zombie process

What causes a process to become a zombie in an operating system?

AThe process is waiting for input/output to complete
BThe process is blocked due to a deadlock
CThe process is currently running on the CPU
DThe process has finished execution but its parent has not yet read its exit status
Attempts:
2 left
💡 Hint

Think about what happens after a process ends but before the system cleans it up.

🚀 Application
expert
3:00remaining
Determine the output of process ID code snippet

Given the following Python code snippet that uses the os module to create a child process, what will be printed?

import os
pid = os.fork()
if pid == 0:
    print(f"Child process: {os.getpid()}")
else:
    print(f"Parent process: {os.getpid()}, child PID: {pid}")
Intro to Computing
import os
pid = os.fork()
if pid == 0:
    print(f"Child process: {os.getpid()}")
else:
    print(f"Parent process: {os.getpid()}, child PID: {pid}")
ATwo lines printed: one from child showing its PID, one from parent showing its PID and child's PID
BOnly one line printed from the parent process showing its PID
COnly one line printed from the child process showing its PID
DSyntaxError because os.fork() is not valid in Python
Attempts:
2 left
💡 Hint

Remember that os.fork() creates a new process that runs the same code after the fork.