OS Ch2 Lecture Notes

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

1/171

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:33 PM on 9/11/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

172 Terms

1
New cards

Operating System

Software that provides an environment for applications to execute while managing and controlling the underlying hardware.

2
New cards

Operating-System Service

A function provided by the operating system to applications or users, such as program execution, I/O, file manipulation, communication, and error detection.

3
New cards

User Interface

A mechanism through which users interact with a computer, such as a CLI, GUI, touch interface, or batch interface.

4
New cards

Shell

A user-space command interpreter that reads and executes commands by requesting operating-system services. It is normally not part of the kernel.

5
New cards

Command-Line Interface (CLI)

A text-based interface in which users enter commands, such as bash, zsh, PowerShell, or cmd.exe.

6
New cards

Program Execution

An OS service that loads a program into memory, establishes its execution environment, begins execution, handles termination, and reclaims resources.

7
New cards

I/O Operations

Operating-system services that allow applications to communicate with devices such as disks, keyboards, displays, network interfaces, printers, and USB devices.

8
New cards

Why shouldn't applications normally access hardware directly?

The operating system provides controlled abstractions while device drivers handle hardware-specific details, improving safety and consistency.

9
New cards

File-System Manipulation

OS services that allow programs to create, delete, open, close, read, write, and obtain information about files and directories.

10
New cards

Common UNIX file operations

open(), read(), write(), close(), lseek(), stat(), and unlink().

11
New cards

Process Communication

The exchange of information between processes on the same computer or across a network.

12
New cards

Two major process communication models

Shared memory and message passing.

13
New cards

Shared Memory

A communication model in which multiple processes access a common region of memory.

14
New cards

Why does shared memory usually require synchronization?

To prevent race conditions when multiple processes access or modify the same memory.

15
New cards

Message Passing

A communication model in which processes exchange messages rather than directly sharing memory.

16
New cards

Examples of message-passing mechanisms

Pipes, sockets, and message queues.

17
New cards

Error Detection

An operating-system service that detects and responds to problems such as memory errors, disk failures, illegal instructions, network failures, and file-system corruption.

18
New cards

Resource Allocation

The OS determines how CPU time, memory, storage, I/O devices, and network bandwidth are distributed among competing processes.

19
New cards

CPU Scheduler

The operating-system component that decides which ready process executes next.

20
New cards

Accounting

Tracking operating-system resource usage such as CPU time, memory consumption, disk usage, network traffic, process counts, and I/O activity.

21
New cards

Examples of Linux accounting and monitoring tools

top, ps, time, free, and df.

22
New cards

Protection

Determines whether a user or process is permitted to access a particular resource.

23
New cards

Security

Protects the system against unauthorized access, attacks, and other threats.

24
New cards

Examples of OS protection and security mechanisms

Authentication, file permissions, process isolation, memory protection, access control, and encryption.

25
New cards

Command Interpreter

Another name for a shell; a program that reads, parses, and executes user commands.

26
New cards

What usually happens when a shell receives the command ls?

The shell creates or uses a process and launches the ls program rather than performing the directory listing itself.

27
New cards

System Call

A controlled mechanism through which a user-mode program requests a service from the operating-system kernel.

28
New cards

User Mode

A restricted CPU execution mode used by ordinary applications, libraries, and shells.

29
New cards

Kernel Mode

A privileged CPU execution mode used by the kernel and components such as device drivers, the scheduler, and memory manager.

30
New cards

Privileged Instruction

An instruction that normally can only be executed in kernel mode because it could affect the entire system.

31
New cards

Why can't normal user programs execute privileged instructions?

Restricting privileged instructions protects the system from incorrect or malicious programs.

32
New cards

What happens when a system call is made?

The application requests a service, the CPU transfers control to the kernel and enters kernel mode, the kernel performs the operation, and control returns to user mode.

33
New cards

System-Call Interface

The controlled boundary through which user-space programs invoke operating-system kernel services.

34
New cards

API

A programmer-visible, source-level interface that specifies how software requests a service.

35
New cards

System Call vs API

An API is the programmer-visible interface, while a system call is the actual request made to the operating-system kernel.

36
New cards

Is every library function a system call?

No. A library function may operate entirely in user space or invoke one or more system calls.

37
New cards

printf() vs write()

printf() is normally a C library function, while write() is associated with the operating system's system-call interface.

38
New cards

POSIX

Portable Operating System Interface, a standard programming interface used by UNIX-like operating systems to improve source-code portability.

39
New cards

Important POSIX calls in CSI 4337

fork(), exec(), waitpid(), open(), read(), write(), close(), and dup2().

40
New cards

Major categories of system calls

Process control, file management, device management, information maintenance, communication, and protection.

41
New cards

Process-Control System Calls

System calls that create or terminate processes, load programs, wait for state changes, deliver signals, or obtain process information.

42
New cards

Examples of process-control system calls

fork(), exec(), waitpid(), exit(), kill(), and getpid().

43
New cards

File-Management System Calls

System calls used to open, read, write, close, seek within, inspect, or delete files.

44
New cards

Typical file lifecycle

open → read or write operations → close.

45
New cards

Device-Management System Calls

Controlled operations for requesting, releasing, reading, writing, or configuring hardware devices.

46
New cards

Information-Maintenance System Calls

Calls that obtain information such as time, process ID, user ID, file metadata, system information, and resource usage.

47
New cards

Examples of information-maintenance calls

getpid(), getuid(), and stat().

48
New cards

Communication System Calls

Calls that provide interprocess communication through mechanisms such as pipes, sockets, message queues, and shared memory.

49
New cards

Examples of communication system calls

pipe(), socket(), send(), recv(), and shm_open().

50
New cards

Protection System Calls

Calls used to control ownership, permissions, credentials, and user identity.

51
New cards

Examples of protection-related calls

chmod(), chown(), and setuid().

52
New cards

Three common ways to pass system-call parameters

Registers, a memory block, or the stack.

53
New cards

Passing parameters using registers

Arguments are placed directly into CPU registers before the system call.

54
New cards

Advantage of register parameter passing

It is fast.

55
New cards

Limitation of register parameter passing

The number and size of arguments are limited by the available CPU registers.

56
New cards

Passing parameters using a memory block

A register contains the address of a memory structure containing the system-call parameters.

57
New cards

Passing parameters using the stack

System-call parameters are placed on the process stack for the kernel to access.

58
New cards

System Services

Ordinary user-space programs that provide convenient environments for program development and execution. They are not kernel entry points.

59
New cards

Examples of system services

File utilities, editors, compilers, assemblers, linkers, loaders, debuggers, shells, networking programs, monitoring tools, and background services.

60
New cards

Examples of Linux system programs

cp, mv, rm, ls, gcc, g++, gdb, ssh, ps, top, and systemctl.

61
New cards

Three important levels between a user command and the kernel

Application or system program → Library or API → System call → Kernel.

62
New cards

System Program vs System Call

A system program is an ordinary user-space application, while a system call is a controlled request for a kernel service.

63
New cards

Compiler

Translates source code into machine instructions and metadata, usually producing an object file.

64
New cards

Object File

Compiled machine code and metadata that has not yet been combined into a complete executable.

65
New cards

Linker

Combines object files and libraries and resolves references among them to produce an executable.

66
New cards

Loader

Places an executable into memory, maps required code and data, connects dynamic libraries, establishes the execution context, and transfers control to the program.

67
New cards

Program creation and execution sequence

Source code → Compiler → Object file → Linker → Executable → Loader → Running process.

68
New cards

Static Linking

Required library code is copied directly into the executable.

69
New cards

Advantages of static linking

Simpler deployment because fewer external libraries are required at runtime.

70
New cards

Disadvantages of static linking

Larger executables, duplicated library code, and library updates usually require relinking.

71
New cards

Dynamic Linking

Libraries are associated with a program at load time or runtime rather than being completely copied into the executable.

72
New cards

Advantages of dynamic linking

Smaller executables, libraries can be shared between processes, and compatible library updates may not require rebuilding applications.

73
New cards

Linux shared-library extension

.so

74
New cards

macOS shared-library extension

.dylib

75
New cards

Windows shared-library extension

.dll

76
New cards

Why are compiled applications normally operating-system specific?

The executable format, system-call interface, libraries, runtime environment, and ABI must match the operating system.

77
New cards

Linux executable format

ELF.

78
New cards

Windows executable format

PE.

79
New cards

macOS executable format

Mach-O.

80
New cards

ABI

Application Binary Interface; the binary-level conventions that determine how compiled components interact.

81
New cards

What does an ABI define?

Calling conventions, register usage, data layout, executable format, and binary library or system interfaces.

82
New cards

API vs ABI

An API defines how source code calls services, while an ABI defines how already-compiled components interact at the binary level.

83
New cards

Does POSIX guarantee the same compiled binary runs on every UNIX-like OS?

No. POSIX improves source-code portability but does not guarantee binary compatibility.

84
New cards

Ways to improve software portability

Standard APIs, cross-platform libraries, virtual machines, interpreters, and bytecode-based runtimes.

85
New cards

Examples of cross-platform libraries

Qt, SDL, and Boost.

86
New cards

Policy

Determines what decision or choice should be made by the operating system.

87
New cards

Mechanism

Determines how a particular operating-system operation is performed.

88
New cards

Policy vs Mechanism

Policy answers "what should be done?" while mechanism answers "how is it done?"

89
New cards

CPU scheduling policy example

Deciding whether process A or process B should run next.

90
New cards

CPU scheduling mechanism example

Pausing a process, saving its registers, restoring another process's registers, and resuming execution.

91
New cards

Why separate policy from mechanism?

It allows policies to change without redesigning the underlying implementation mechanism.

92
New cards

Common operating-system design goals

Usability, performance, reliability, security, scalability, compatibility, flexibility, and maintainability.

93
New cards

Why can operating-system design goals conflict?

Improving one property may hurt another, such as additional security checks increasing overhead.

94
New cards

What languages are modern kernels primarily written in?

Mostly C or C++, with assembly for architecture-specific and very low-level operations.

95
New cards

Common uses of assembly in an operating system

Boot code, interrupt entry, context switching, and processor-specific operations.

96
New cards

Monolithic Kernel

A kernel architecture in which most operating-system services execute together in kernel space.

97
New cards

Advantages of a monolithic kernel

High performance, fast communication between kernel components, and low IPC overhead.

98
New cards

Disadvantages of a monolithic kernel

A large trusted kernel, kernel bugs can affect the whole system, and the codebase can be difficult to maintain.

99
New cards

Traditional UNIX kernel architecture

Monolithic.

100
New cards

Linux kernel architecture

Largely monolithic with extensive support for loadable modules.