OS - Processes, Threads, Interrupt/Traps, Mode/Context Switches, Atomicity, CPU Scheduling, Busy Waiting | Quizlet

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/44

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 11:15 PM on 4/4/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

45 Terms

1
New cards

What is a program?

A program is a set of instructions stored on a disk designed to perform a task.

2
New cards

What is a process?

A process is an active instance of a program with its own execution context and owned resources, running on the CPU while being stored in the RAM with a PC specifying the next instruction.

3
New cards

T/F Only one process can run the same program.

F. Multiple processes can run on the same program.

4
New cards

What is the main difference between a process and a thread?

A process has its own resources like address space not shared between processes, while a thread is a unit of execution inside a process that shares its resources.

5
New cards

How is the process address space divided and what does each section handle?

(1) Text (executable code/instructions)

(2) Stack (temporary data storage)

(3) Heap (dynamically allocated memory during runtime)

(4) Data (global variables)

6
New cards

What are the typical states of a process?

(1) New

(2) Ready

(3) Running

(4) Waiting (Blocked)

(5) Terminated

7
New cards

What is an OS?

An OS is a software between user/applications and hardware that provides abstraction, resource management, protection and efficiency.

8
New cards

What are the key motivations of the OS? (5)

(1) Support for concurrency

(2) Virtualization

(3) Portability

(4) Deal with diversity

(5) Transparency

9
New cards

What are the core purposes of an OS? (3)

(1) Abstraction (hide OS complexity)

(2) Resource management (share CPU, memory, I/O. -> share hardware efficiently)

(3) Protection (prevent apps from harming OS/other apps)

10
New cards

What are the responsibilities of an OS?

(1) Memory Management

(2) I/O Management

(3) Process Management

(4) File Management

11
New cards

When forking, who gets the PID and who gets 0?

The parent process from who we originally forked from gets the PID and the child process gets 0.

12
New cards

Why is it useful for the parent and child to have different values?

To allow the child and the parent process to differentiate each other by testing the value of x. (let the parent know it is the parent process and the child that it is the child)

13
New cards

What are the two ways a process can be terminated?

(1) The process calls exit(status) on itself.

(2) The parent terminates it. (abort/kill)

14
New cards

What are the special cases of termination and how do they happen?

(1) Orphan: The parent is terminated before the child.

(2) Zombie: The child is terminated, parent did not call wait().

15
New cards

What is a system call?

A system call is a controlled request for OS services, invoked via a trap.

16
New cards

What are the steps of a system call?

(1) Put syscall number in register

(2) Execute trap

(3) Switch to kernel mode

(4) OS executes code

(5) Return to user mode

17
New cards

What is a mode switch?

A mode switch allows for switching between user and kernel mode.

18
New cards

What is a context switch?

A context switch allows for saving a process state and restoring another.

19
New cards

What is the key difference of the switches?

A mode switch is focused on privilege levels

20
New cards

who is allowed to use what. A context switch is focused on which process runs.

21
New cards

What does the OS do during a context switch?

Saves the context of execution of one process in its PCB and loads the context of execution of another process.

22
New cards

What is a DMA?

A hardware component that transfers large blocks of data directly between device and memory without using the CPU.

23
New cards

What happens without a DMA?

CPU waits for I/O, performs many copies, handles many interrupts. This makes it inefficient.

24
New cards

What happens with a DMA? (Advantages)

Fewer CPU operations, fewer interrupts, CPU executes other work in parallel.

25
New cards

What is an I/O device?

Devices that humans/systems use to communicate with the computer.

26
New cards

What is an interrupt?

A hardware generated signal for controlled entry into OS causing the CPU to run OS interrupt handlers.

27
New cards

What is a trap?

A software generated interrupt, used for system calls or raised on errors.

28
New cards

What is a buffer?

A buffer is a designated, temporary storage in physical memory for data that is being moved between processes/locations.

29
New cards

What are buffers used for?

(1) Handle speed mismatch -> Process must wait for the relatively slow I/O to complete before it can send new data (or vice versa)

(2) Handle granularity mismatch -> Application may expect to receive data in smaller or larger pieces than the data sent by the I/O (and vice versa)

(3) Allow process switching during I/O

30
New cards

In what aspects do the CPU scheduling frameworks differ from each other?

(1) When to schedule: determines at which events the scheduler is activated.

(2) Who to schedule: determines which process is chosen next based on a priority function among ready processes (e.g. shortest job, earliest arrival).

(3) What arbitration rule: determines how to choose between processes with equal priority (e.g. FCFS)

31
New cards

What are the three main CPU scheduling algorithms?

(1) FCFS (First-Come First-Serve)

(2) SJF (Shortest Job First)

(3) RR (round Robin)

32
New cards

When is something considered atomic?

When an instruction contains only ONE reference to a shared variable.

33
New cards

If x and y are shared variables and z is private, is the statement x := y * z atomic? Why or why not?

No. It contains two references to shared variables (reading y and writing to x). To be atomic, it can have only one shared reference.

34
New cards

Why is y++ generally not considered atomic?

At machine level, we need to do 3 things for this instruction. We read y, increment y, and write y. This involves two references to a shared variable (one read, one write).

35
New cards

What is a race condition?

A situation where the correctness of a concurrent program depends on the specific interleaving or order in which instructions are chosen for execution.

36
New cards

What is an example of a race condition?

In a program that assumes a state is not changed between a test (like if (x > 0)) and an action (like x--), another thread could change x in between, leading to an error.

37
New cards

What is interference?

When the truth of an assumption which would be true in local reasoning, is made false by the actions of a different concurrent task.

38
New cards

What are the four correctness concerns in concurrent programs or systems?

(1) Functional Correctness (Mutual Exclusion)

(2) Minimal waiting

(3) Absence of deadlocks

(4) Fairness

39
New cards

If two POSIX processes P1 and P2 both execute x := x + 1 (starting at x = 0), why is the final value of x always 1 in both processes?

The final value is 1 in both. Because they are processes, they have separate, non-shared memory spaces

40
New cards

each increments its own private copy of x.

41
New cards

If two Threads T1 and T2 execute x := x + 1 and x := x + 2 concurrently (starting at x = 0), list all the possible final values of x.

Possible values are 1, 2, or 3.

3: Sequential execution.

1 or 2: Interleaved execution where one thread overwrites the other's update.

42
New cards

Why is communication and context switching generally faster between threads than between processes?

Threads share the same address space. Creation and context switching are faster because the OS does not need to copy memory spaces or switch page tables.

43
New cards

What is busy waiting?

A task or process repeatedly checks a condition in a loop without going to sleep or yielding the CPU. Instead of being suspended by the OS, it keeps running and executing instructions until required conditions are true.

44
New cards

When is busy waiting acceptable?

(1) When the waiting time is guaranteed to be short.

(2) When it is the only task the processor can perform.

45
New cards

Why is busy waiting generally discouraged?

It wastes CPU cycles that could be used by other productive processes, leading to decreased system efficiency and potentially causing priority inversion.