OS Exam 1 Review

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

1/308

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:23 PM on 9/27/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

309 Terms

1
New cards

What is an operating system, in one sentence?

A program that mediates between application programs and the hardware.

2
New cards

What are the two main things an OS does at a high level?

It provides abstractions to simplify building applications, and it allows application programs to coexist peacefully.

3
New cards

Name three abstractions an OS provides and what they replace.

Files instead of "bytes on a disk," contiguous memory regions instead of "bits in a RAM chip," and processes instead of raw execution on hardware.

4
New cards

How does an OS allow application programs to coexist peacefully?

By enforcing security policies and enforcing safety measures.

5
New cards

Besides abstraction and coexistence, what else does an OS provide?

Effective/efficient usage of hardware resources.

6
New cards

What two things must the OS control that must be denied to user programs?

Control of I/O devices and control of access to the hardware.

7
New cards

Why must the OS deny hardware/I/O control to user programs?

For protection and for abstraction/ease of use.

8
New cards

How does hardware support the OS's need for exclusive control of devices?

It supports two (or more) modes of operation — "supervisor" (privileged) mode and "user" mode.

9
New cards

What is true of privileged instructions?

They can only be executed in supervisor mode; they cannot be executed in user mode.

10
New cards

Name two hardware mechanisms used to implement the supervisor/user mode distinction.

A mode bit in the processor, or protection rings (e.g., Intel Pentium uses 4 protection rings).

11
New cards

In which mode does OS code run vs. user program code?

OS code runs in supervisor mode; user program code runs in user mode.

12
New cards

What three events cause a switch from user mode to supervisor mode?

Interrupts, exceptions, and trap instructions.

13
New cards

What instruction is used to switch back from supervisor mode to user mode?

The RTI (return from interrupt) instruction.

14
New cards

What triggers an interrupt?

A hardware device needing service.

15
New cards

What triggers an exception?

The user program "acting silly" — e.g., a segmentation violation or bus error.

16
New cards

What triggers a trap instruction?

The user program explicitly requesting an OS service (a system call).

17
New cards

List the steps the OS takes when handling an interrupt.

Hardware calls the OS at a pre-specified location;

OS saves the user program's state;

OS identifies the device and cause;

OS responds to the interrupt;

OS restores the (possibly different) user program's state;

OS executes RTI to return.

18
New cards

What is the key fact about interrupts with respect to the user program?

None of it is visible to the user program — it continues exactly where it was interrupted.

19
New cards

List the steps the OS takes when handling an exception.

Hardware calls the OS;

OS identifies the cause;

if the program has a handler, OS adjusts program state to call it;

OS executes RTI to return;

if no handler exists, OS kills the program and runs another.

20
New cards

What is the key fact about exceptions with respect to the user program?

Their effects ARE visible to the user program and cause abnormal execution flow.

21
New cards

List the steps the OS takes when handling a system call.

User program executes a trap instruction;

hardware calls the OS;

OS identifies the requested service and parameters;

OS executes the service;

OS sets a register with the result;

OS executes RTI to return.

22
New cards

What is the key fact about system calls with respect to the user program?

To the user program it appears as an ordinary function call executed under program control.

23
New cards

Compare interrupts, exceptions, and system calls in terms of visibility to the user program.

Interrupts are invisible, exceptions are visible and disrupt flow, and system calls appear as normal (voluntary) function calls.

24
New cards

Why is an OS described as a "strange" program?

It is entered from different locations in response to external events, has no single thread of control (can be invoked simultaneously by two different events), is not supposed to terminate, and can execute any instruction in the machine.

25
New cards

How many times is an OS's main() function called, and when?

Only once, during boot.

26
New cards

In what sense is the OS "just a program" like any other?

It consumes resources (like memory) and can do silly things (like generate an exception).

27
New cards

What are the four classic OS structure/organization types?

Monolithic (spaghetti code), layered, microkernel, and virtual machine organization.

28
New cards

Describe the monolithic OS structure and give an example.

All OS modules (device drivers, file systems, memory manager, process manager, security, network support, etc.) are combined together with no strict separation; the classic example is UNIX.

29
New cards

Describe the layered OS structure and give an example.

OS modules are organized into layers, each with a well-defined interface, built on top of a machine-dependent kernel and a Hardware Adaptation Layer (HAL); the example given is Windows.

30
New cards

What is the HAL in a layered OS?

The Hardware Adaptation Layer — the machine-dependent basic implementation layer at the bottom of a layered OS (e.g., Windows) that the rest of the OS is built upon.

31
New cards

Describe the microkernel OS structure and give examples.

Core OS functions run as out-of-kernel servers communicating via basic message-passing support in a minimal kernel;

examples are QNX, Mach, and macOS

(A microkernel is a stripped-down, minimal kernel that only handles absolute essentials like basic memory and scheduling.

Instead of living inside the kernel, major operating system features (like file systems and drivers) run outside of it as isolated programs called servers. Because these servers are separated, they must communicate by sending messages back and forth through the minimal kernel.)

32
New cards

What is the key idea distinguishing a microkernel from a monolithic kernel?

Main OS functions (file systems, memory manager, process manager, etc.) are implemented as separate out-of-kernel servers rather than inside one kernel, communicating via message passing.

33
New cards

Describe the virtual machine OS organization and give examples.

A VM/hypervisor layer gives a hardware abstraction to multiple OS instances running on top of it, each with its own applications;

examples are IBM mainframes (OS/370), VMware, and cloud computing.

34
New cards

What is another name for the VM layer in a virtual machine organization?

The hypervisor.

35
New cards

What does the boot program (e.g., BIOS) do before loading the OS?

Examines/checks machine configuration (CPUs, memory, devices), builds a configuration structure describing the hardware, then loads the OS and gives it that configuration structure.
(The boot program acts as the computer's initial inventory manager and setup crew. Before the operating system takes over, it performs three quick steps:

  1. Hardware Check: It examines and tests the physical machine configuration, making sure the components like the CPUs, RAM (memory), and storage devices are attached and working properly.

  2. Map the System: It builds a detailed digital map (a configuration structure) that describes exactly what hardware is plugged into the computer.

  3. Hand-off: It locates and loads the operating system into the computer's memory, hands over that hardware map so the OS knows what it has to work with, and steps aside.

)


36
New cards

What does OS initialization do after being loaded?

Initializes kernel data structures, initializes the state of all hardware devices, and creates initial processes to start operation (e.g., getty in UNIX, the Windowing system in NT).

37
New cards

What does the OS do after basic processes have started, if no user programs are available?

It enters the idle loop.

38
New cards

Give examples of what an OS might do in the idle loop.

Execute an infinite loop (UNIX), perform system management/profiling, halt the processor into low-power mode (notebooks), or compute some function (DEC VMS on VAX computed Pi).

39
New cards

What three kinds of events wake the OS from the idle loop?

Interrupts from hardware devices, traps from user programs, and exceptions from user programs.

40
New cards

What is a process?

An abstraction that supports running programs.

41
New cards

Can multiple processes run the same program?

Yes — different processes may run several instances of the same program.

42
New cards

How are processes typically organized in most systems?

In a tree, with the root being the first process created.

43
New cards

What two resources are minimally required for a process?

Memory to contain the program's code and data, and a set of CPU registers to support execution.

44
New cards

What does a "program" consist of (four components)?

Code (machine instructions), data, DLLs (libraries not compiled/linked with the program), and mapped files.

45
New cards

What are the three classifications of program data?

Initialized variables (globals), dynamically allocated variables (malloc/new), and stack variables (automatic variables and function arguments).

46
New cards

What is a DLL in this context?

A library containing code and data that was not compiled or linked with the program, possibly shared with other programs that use it.

47
New cards

What are mapped files used for?

Memory segments containing variables via mmap(), frequently used in database programs.

(mapped files are sections of computer memory linked directly to a file on your disk using the mmap() command, allowing databases to read and change massive amounts of data instantly.)

48
New cards

Describe the pipeline for preparing a program from source to executable.

Source file → compiler/assembler → .o (object) files → linker → executable file.

49
New cards

What must an executable file follow, and give examples of such formats.

A standard format, such as ELF (Linux/Windows), XCOFF (AIX), or EXEC (BSD 4.3).

50
New cards

What sections typically appear in an executable file?

Header, code, initialized data, BSS, symbol table, line numbers, and external references.

51
New cards

What is BSS?

The section for uninitialized (zero-initialized) global/static data in an executable/process image.

52
New cards

What does the OS do to start running a program?

It creates a process with memory allocated for it.

53
New cards

List the steps performed by the loader.

Reads/interprets the executable file;

sets up the process's memory with code and data from the executable;

pushes argc, argv, envp onto the stack;

sets CPU registers properly and calls __start() (part of CRT0).

54
New cards

What happens after __start() runs?

The program starts running at __start(), which calls main(); at this point we say the "process" is running, no longer thinking of it as a "program."

55
New cards

What happens when main() returns?

CRT0 calls exit(), which destroys the process and returns all its resources.

56
New cards

What regions/segments make up a process's address space?

Code, initialized data, BSS, heap, stack, DLLs, and mapped segments.

57
New cards

What are the five states in the basic process life cycle?

Start, Ready, Running, I/O Wait, and Done.

58
New cards

What transition moves a process from Start to Ready?

Process creation, with resources allocated, and the process loaded into main memory.

59
New cards

What transition moves a process from Ready to Running?

It is scheduled/dispatched to run (implied: scheduler picks it).

60
New cards

What causes a process to move from Running to I/O Wait?

An I/O request.

61
New cards

What causes a process to move from I/O Wait back to Ready?

I/O completing (I/O done).

62
New cards

What causes a process to move from Running to Done?

The process calls exit() (or otherwise finishes), and resources are deallocated.

63
New cards

What extra state is added to the process life cycle to account for parent/child interaction, and why?

The Zombie state — a process that has called exit() but whose parent hasn't yet collected its result via wait().

64
New cards

Define "process context."

The process context consists of its address space and its CPU registers.

65
New cards

What does it mean to say we are "running the context of process p"?

That p's address space is in memory and the CPU registers are being used to run p.

66
New cards

What is true of a stopped process's context (e.g., waiting for I/O)?

Its context is not active.

67
New cards

Define context switching.

The act of saving one process's registers/context to memory and loading another process's registers/context into the CPU so it can run.

68
New cards

What three events can cause a context switch?

An interrupt occurring, a process issuing a system call, or a process causing an exception.

69
New cards

What is the explicit cost of context switching?

The cost of loading and storing CPU registers from/into main memory.

70
New cards

What are the implicit costs of context switching?

Pipeline drain time in a pipelined CPU; a burst of cache misses for the newly-switched-in process; and TLB flush/replacement causing slowdown.

71
New cards

Why does context switching overhead matter?

It is a big factor in the overall efficiency of an operating system.

72
New cards

What are the three main components of the Process Manager?

The scheduler, basic process implementation (data structures + multiplexing support), and support for process manipulation (creation, destruction, migration, reporting).

73
New cards

What are the four basic UNIX process manipulation system calls?

fork(), exec(), wait(), and exit().

74
New cards

What UNIX system call is used for process signaling?

kill()

75
New cards

What UNIX system calls provide process control?

ptrace(), nice(), and sleep().

76
New cards

What is the "creator" process called relative to the process it creates?

The parent process (the created one is the child process).

77
New cards

In UNIX, what is the second process created and what is its role?

init — it creates all the gettys (login processes) and daemons, should never die, and controls system configuration (e.g., number of processes, priorities).

78
New cards

What does fork() do?

Creates a child process that inherits identical copies of all the parent's variables/memory and identical copies of all the parent's CPU registers (except one).

79
New cards

What does fork() return to the child vs. the parent?

To the child it returns 0; to the parent it returns the child's process identifier (pid).

80
New cards

Describe a simple implementation of fork().

Allocate memory for the child process, then copy the parent's memory and CPU registers into the child's — this is expensive.

81
New cards

What is the code-organization limitation of fork()?

Parent and child code must be in the same "program," limiting its usefulness for general-purpose process creation and getting unwieldy if many children are needed.

82
New cards

What happens to open files/network connections across fork()?

The child inherits all of the parent's open files and network connections, which is tricky to manage and wasteful if the child doesn't need them.

83
New cards

What is the overall characteristic/downside of fork() emphasized repeatedly?

It is expensive (due to copying memory and registers).

84
New cards

What does exec() do?

Allows a process to "load" a different program and start execution at _start, specifying argc and argv — it's the same process but running a different program.

85
New cards

What are the two implementation options for exec()?

Overwrite the current memory segments with new values, or allocate new memory segments (load them, then deallocate the old ones).

86
New cards

Why are fork() and exec() almost always called together?

Because in ~99% of cases fork() is immediately followed by exec(), making the memory copy done by fork() essentially wasted work.

87
New cards

What alternative to sequential fork()+exec() combines them into one call?

OS/2 combined them into a single call.

88
New cards

What is vfork()?

A "lightweight fork" system call that creates a process without duplicating an identical memory image, under the assumption the child will call exec() almost immediately.

89
New cards

What does exit() do?

Takes the program's result as an argument, closes all open files/connections, deallocates memory, deallocates most OS structures for the process, and cleans up waiting zombies.

90
New cards

What happens in exit() if the parent is still alive?

The process holds its result value until the parent requests it — it enters the zombie/defunct state rather than fully dying.

91
New cards

What happens in exit() if the parent is not alive?

All data structures are deallocated immediately and the process is fully dead.

92
New cards

What is a "zombie" (defunct) process?

A process that has called exit() and finished, but whose exit status hasn't yet been collected by its parent via wait().

93
New cards

What does wait() do?

Puts the parent to sleep waiting for a child's result; when a child calls exit(), the OS unblocks the parent and returns the exit value and the child's pid.

94
New cards

What does wait() do if there are no children alive?

It returns immediately.

95
New cards

What does wait() do if a zombie child already exists?

It returns that zombie's value immediately and deallocates the zombie.

96
New cards

What does nice() do?

Specifies a process's base (initial) priority.

97
New cards

What happens to UNIX process priority over time as it runs?

Priority decays as the process consumes CPU.

98
New cards

What does ptrace() do?

Allows one process to be put under the control of another for debugging — the controller can set breakpoints, examine registers, etc.

99
New cards

What does sleep() do?

Puts a process on a timer queue, waiting for a specified number of seconds, supporting alarm-like functionality.

100
New cards

What kinds of events does the OS translate into asynchronous signals?

Input/output events, alarms, and exceptions (e.g., memory access violations, illegal instructions, overflow).