Operating Systems HW1–HW3: Architecture, Processes, Scheduling, Synchronization

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

1/147

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:48 AM on 10/9/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

148 Terms

1
New cards

HW1 Q1: Which best describes the role of the OS in a computer system? A) Provides basic computing resources such as CPU, memory, and I/O devices B) Solves the computing problems of users through word processors, browsers, or games C) Controls and coordinates the use of hardware among various applications and users D) None of the above

C) Controls and coordinates the use of hardware among various applications and users

2
New cards

HW1 Q2: Which component provides an environment for users to execute programs efficiently, allocates resources fairly, supervises program execution, and manages I/O devices? A) Hardware B) Operating System C) Application Programs D) Compiler

B) Operating System

3
New cards

HW1 Q3: Which best describes the basic computer system organization? A) A set of application programs that solve user problems B) One or more CPUs, memory, and I/O devices managed by device controllers connected through a common bus C) An OS that controls and coordinates access to hardware D) A compiler that translates high-level programs into machine instructions

B) One or more CPUs, memory, and I/O devices managed by device controllers connected through a common bus

4
New cards

HW1 Q4: Which statement about interrupts is true? A) Interrupts are only generated by hardware, never by software B) An interrupt transfers control to the interrupt service routine (ISR), allowing the OS to respond to events C) Software interrupts are used only to start new programs D) An OS is never interrupt-driven

B) An interrupt transfers control to the interrupt service routine (ISR), allowing the OS to respond to events

5
New cards

HW1 Q5: Which best distinguishes main memory from secondary storage? A) Main memory is nonvolatile and larger B) Main memory is volatile and directly accessed by the CPU, while secondary storage is nonvolatile and provides large capacity C) Both are volatile but differ in speed D) Secondary storage is directly accessed by the CPU

B) Main memory is volatile and directly accessed by the CPU, while secondary storage is nonvolatile and provides large capacity

6
New cards

HW1 Q6: Which best explains the purpose of dual-mode operation? A) Lets multiple CPUs share memory without conflicts B) Provides user and kernel modes so the system can distinguish application execution from OS execution, protecting the OS from improper access C) Lets the CPU run 32-bit and 64-bit instructions in one program D) Ensures only user programs can directly access hardware

B) Provides two modes, user and kernel, so the system can distinguish application execution from OS execution, protecting the OS from improper access

7
New cards

HW1 Q7: Which correctly distinguishes multiprocessor systems from dual-core processors? A) Multiprocessor = multiple cores on one chip; dual-core = separate chips B) Multiprocessor systems improve throughput and reliability with multiple processors; a dual-core processor integrates two cores on the same chip, often used in server systems C) Multiprocessors are less reliable; dual-core is only for gaming D) They are the same

B) Multiprocessor systems improve throughput and reliability using multiple processors; a dual-core processor integrates two cores on the same chip

8
New cards

HW1 Q8: Which correctly contrasts shared memory and message passing? A) Shared memory is simpler since the OS moves data B) Message passing is faster because no kernel involvement is needed C) Shared memory lets processes exchange data through a common memory region, while message passing has the OS move packets of data between processes D) Both require writing into each other's private address space

C) Shared memory = processes access a common memory region; message passing = the OS moves packets of data between processes

9
New cards

HW1 Q9: A boot block ____. A) typically only knows the location and length of the rest of the bootstrap program B) is sophisticated enough to load the OS and begin its execution C) is composed of multiple disk blocks D) is composed of multiple disk cylinders

A) typically only knows the location and length of the rest of the bootstrap program

10
New cards

HW1 Q10: Which correctly matches the OS monitoring/debugging technique with its purpose? A) Debugging: finding and fixing errors B) Logging: recording error information into files C) Tracing: collecting step-by-step data about events like system calls D) Profiling: sampling to detect performance trends E) All of the above

E) All of the above

11
New cards

HW2 Q1: Which components of program state are shared across threads in a multithreaded process? A) Register values B) Program counter C) Global variables D) Stack memory

C) Global variables

12
New cards

HW2 Q2: In the context of scheduler activations, what is an upcall? A) A communication from the kernel to the thread library B) A request from a user thread to the kernel C) A system call made by an application D) A method to cancel a thread

A) A communication from the kernel to the thread library

13
New cards

HW2 Q3: What is the purpose of a Process Control Block (PCB)? A) To store the compiled program code B) To manage the process stack C) To hold information associated with each process D) To execute process instructions

C) To hold information associated with each process

14
New cards

HW2 Q4: In process creation, what does the fork() system call do in UNIX? A) Terminates a process B) Creates a new process C) Replaces the process' memory space D) Waits for a child process to terminate

B) Creates a new process

15
New cards

HW2 Q5: What is a zombie process? A) A process that has terminated but whose parent hasn't called wait() B) A process without a parent C) A process stuck in an infinite loop D) A process that consumes excessive resources

A) A process that has terminated but whose parent hasn't called wait()

16
New cards

HW2 Q6: In the Producer-Consumer problem using shared memory, when is the buffer considered full? A) When in == out B) When ((in + 1) % BUFFER_SIZE) == out C) When in > out D) When BUFFER_SIZE is reached

B) When ((in + 1) % BUFFER_SIZE) == out (in == out means empty)

17
New cards

HW2 Q7: Which is NOT a benefit of using threads? A) Responsiveness B) Resource Sharing C) Economy D) Increased memory usage

D) Increased memory usage

18
New cards

HW2 Q8: In multicore programming, what does parallelism imply? A) Threads are interleaved over time B) A system can perform more than one task simultaneously C) Only one task at a time D) Threads always run sequentially

B) A system can perform more than one task simultaneously

19
New cards

HW2 Q9: Which multithreading model maps many user-level threads to a single kernel thread? A) Many-to-One B) One-to-One C) Many-to-Many D) One-to-Many

A) Many-to-One

20
New cards

HW2 Q10: What is the primary advantage of using thread pools? A) Increases the number of threads B) Allows unlimited thread creation C) Limits the number of threads that exist at any one point D) Eliminates the need for thread synchronization

C) It limits the number of threads that exist at any one point

21
New cards

HW3 Q1: How is the length of the next CPU burst typically estimated in SJF scheduling? A) Randomly B) By averaging the lengths of previous CPU bursts C) By user input D) By the OS's internal clock

B) By averaging the lengths of previous CPU bursts (exponential averaging)

22
New cards

HW3 Q2: What is processor affinity? A) A process using more CPU time than others B) The preference of a thread to run on the same processor C) A processor running only certain thread types D) How fast a processor switches threads

B) The preference of a thread to run on the same processor

23
New cards

HW3 Q3 (select all): Which are true about Round Robin scheduling? A) If the time quantum is large, it behaves like FIFO B) It always minimizes average waiting time C) If the time quantum is small, the overhead can be too high D) It is suitable for batch processing

A and C

24
New cards

HW3 Q4: What is the primary characteristic of a multilevel queue scheduling algorithm? A) All queues have the same priority B) Processes can move between queues C) Each queue has its own scheduling algorithm D) It uses a single ready queue

C) Each queue has its own scheduling algorithm

25
New cards

HW3 Q5 (select all): Which are true regarding thread scheduling? A) PCS involves competition among all threads in the system B) SCS involves competition among all threads in the system C) PCS is scheduling competition within the process D) SCS is typically done via priority set by the programmer

B and C

26
New cards

HW3 Q6: What is the purpose of push migration in load balancing? A) Move threads from idle to busy processors B) Periodically move tasks from overloaded CPUs to other CPUs C) Prevent threads from migrating D) Assign threads by affinity

B) To periodically move tasks from overloaded CPUs to other CPUs

27
New cards

HW3 Q7: Which statement about test-and-set instructions is TRUE? A) Test-and-set is a software-based solution B) Modern processors provide special hardware instructions, like test-and-set, to perform atomic operations C) Software-based synchronization always works on modern architectures D) Test-and-set only helps single-threaded applications

B) Modern processors provide special hardware instructions, like test-and-set, to perform atomic operations

28
New cards

HW3 Q8: In the semaphore solution to the bounded-buffer problem, mutex, empty and full are initialized to? (n = buffer size) A) mutex = 0, empty = 0, full = n B) mutex = 1, empty = n, full = 0 C) mutex = 1, empty = 0, full = n D) mutex = n, empty = 1, full = 0

B) mutex = 1, empty = n, full = 0

29
New cards

HW3 Q9: Which statement about semaphore waiting queues is TRUE? A) Each entry stores priority and execution time B) block moves a process to the semaphore's waiting queue, and wakeup moves a process from the waiting queue to the ready queue C) Waiting queues are only for binary semaphores D) All waiting processes are unblocked on wakeup

B) block moves a process to the waiting queue; wakeup moves a process from the waiting queue to the ready queue

30
New cards

HW3 Q10: Which POSIX mechanism lets a thread wait for a specific condition to be met before continuing? A) Mutex locks B) Semaphores C) Condition variables D) Barriers

C) Condition variables (pthread_cond_t)

31
New cards

Q: A(n) ____ is the unit of work in a system. A) process B) operating system C) timer D) mode bit

A) process

32
New cards

Protection

Controlling access of processes (or users) to resources

33
New cards

Security

Defense of the system against internal and external attacks (denial-of-service, worms, viruses, trojan horse, man-in-the-middle, etc.)

34
New cards

T/F: Security is equivalent to protection with no difference.

False

35
New cards

Monolithic structure (original UNIX)

A single, static, binary file that runs in a single address space

36
New cards

Monolithic: advantage / disadvantage

Advantage: communication with the kernel is fast. Disadvantage: too many functions packed into one layer

37
New cards

Layered approach

The OS is divided into a number of layers (levels), each built on top of the lower layer. The bottom layer (layer 0) is the hardware; the highest (layer N) is the user interface

38
New cards

Layered: advantage / disadvantage

Advantage: easy to debug (build from the hardware up, testing each layer first). Disadvantage: low efficiency, e.g., connect with I/O

39
New cards

Q: The major difficulty in designing a layered operating system approach is ____

A) appropriately defining the various layers

40
New cards

Microkernel

Moves as much from the kernel into user space; provides just a few essential services, and the rest of the OS is turned into separate user-level programs; communication between user modules uses message passing

41
New cards

Microkernel: benefits / disadvantage

Benefits: easier to extend; more reliable (less code running in kernel mode). Disadvantage: performance overhead of user space to kernel space communication. Example: Mach

42
New cards

Q: A microkernel is a kernel ____

D) that is stripped of all nonessential components

43
New cards

Modules (loadable kernel modules, LKMs)

Uses object-oriented approach; each core component is separate; each talks to the others over known interfaces; each is loadable as needed within the kernel

44
New cards

Modules: ADVANTAGES (not on slides)

Services loaded dynamically as needed without recompiling the kernel; modules call each other directly (no message passing, so faster than microkernel); flexible

45
New cards

Modules: DISADVANTAGES (not on slides)

Modules still run in kernel mode, so a faulty module can crash the whole system; less protection/isolation than a microkernel

46
New cards

Q: ____ allows operating system services to be loaded dynamically

B) Modules

47
New cards

Dual-mode operation

Allows OS to protect itself and other system components: user mode and kernel mode

48
New cards

Which programs run in user mode vs kernel mode?

Application programs run in user mode; OS programs run in kernel mode

49
New cards

Mode bit

Provides ability to distinguish when system is running user code or kernel code: 'user' when a user is running, 'kernel' when kernel code is executing

50
New cards

Q: What is another term for kernel mode? A) supervisor mode B) system mode C) privileged mode D) All of the above

D) All of the above

51
New cards

Q: Which should only be run in kernel mode? Read the clock / Clear memory / Issue an instruction / Turn off interrupts / Modify entries in device-status table

Clear memory, Turn off interrupts, Modify entries in device-status table

52
New cards

Timer

Prevents infinite loop or process hogging resources: set counter to predefined number, OS decrements it, when counter = 0 generate an interrupt. OS sets the timer before turning over control to the user

53
New cards

Q: A ____ can be used to prevent a user program from never returning control to the operating system

D) timer

54
New cards

T/F: Interrupts may be triggered by either hardware or software

True

55
New cards

System calls

Programming interface to the services provided by the OS; typically written in C or C++; mostly accessed by programs via a high-level API rather than direct system call use

56
New cards

System call interface

Invokes the intended system call in OS kernel and returns status of the system call and any return values

57
New cards

Yes/No: System call interface is the boundary between user programs and operating system services

Yes

58
New cards

3 methods to pass parameters to a system call

1) In registers 2) In a block (table) in memory, with the block's address passed in a register (Linux) 3) Pushed onto the stack by the program and popped off by the OS. Block and stack do not limit number or length of parameters

59
New cards

Q: ____ is/are not a technique for passing parameters from an application to a system call

A) Cache memory

60
New cards

T/F: System calls can be run in either user mode or kernel mode

False

61
New cards

Process

A program in execution

62
New cards

Program vs. process

Program is a passive entity stored on disk (executable file); process is active. A program becomes a process when an executable file is loaded into memory

63
New cards

Text section

The compiled program code

64
New cards

Data section

Contains global variables

65
New cards

Heap

Used for dynamic memory allocation; managed via calls to new, delete, free, etc.

66
New cards

Stack

Contains temporary data: function parameters, return addresses, local variables

67
New cards

Memory layout of a process, top (high address) to bottom (low address)

Stack, (free space), heap, data, text. Stack grows down, heap grows up (from the slide's memory layout figure)

68
New cards

Q: The ____ of a process contains temporary data such as function parameters, return addresses, and local variables

D) stack

69
New cards

Process state: New

The process is being created

70
New cards

Process state: Running

Instructions are being executed

71
New cards

Process state: Waiting

The process is waiting for some event to occur

72
New cards

Process state: Ready

The process is waiting to be assigned to a processor

73
New cards

Process state: Terminated

The process has finished execution

74
New cards

Q: A process may transition to the Ready state by A) completion of an I/O event B) awaiting its turn on the CPU C) newly-admitted process D) All of the above

D) All of the above

75
New cards

Process Control Block (PCB)

Information associated with each process (also called task control block)

76
New cards

Context switch

Occurs when the CPU switches from one process to another: the system must save the state of the old process and load the saved state for the new process

77
New cards

Q: A ____ saves the state of the currently running process and restores the state of the next process to run

C) context switch

78
New cards

fork()

System call that creates a new process

79
New cards

exec()

System call used after a fork() to replace the process' memory space with a new program

80
New cards

wait()

Parent waits for termination of a child; returns status information and the pid of the terminated process: pid = wait(&status);

81
New cards

exit()

Process executes last statement and asks the OS to delete it; returns a status value from child to parent; process' resources are deallocated by OS

82
New cards

Cascading termination

If a process terminates, all its children, grandchildren, etc. are terminated; initiated by the OS

83
New cards

Orphan process

A process whose parent terminated without invoking wait()

84
New cards

Q: The ____ process is assigned as the parent to orphan processes

B) init (it periodically invokes wait() to collect the orphan's exit status)

85
New cards

Q: When a child process is created, which is a possibility? A) runs concurrently with parent B) has a new program loaded C) is a duplicate of the parent D) All of the above

D) All of the above

86
New cards

Thread

A basic unit of CPU utilization; comprises a thread ID, a program counter (PC), a register set, and a stack

87
New cards

T/F: A traditional (or heavyweight) process has a single thread of control.

True

88
New cards

T/F: A thread is composed of a thread ID, program counter, register set, and heap.

False (stack, not heap)

89
New cards

T/F: Each thread has its own register set and stack.

True

90
New cards

Concurrency

The execution of the threads will be interleaved over time

91
New cards

Parallelism

A system can perform more than one task simultaneously

92
New cards

T/F: It is possible to have concurrency without parallelism.

True

93
New cards

One-to-One model

Each user-level thread maps to a kernel thread. Drawback: a large number of kernel threads may burden performance. Use case: high-performance apps (web servers, databases)

94
New cards

Many-to-Many model

Allows many user-level threads to be mapped to many kernel threads; OS can create a sufficient number of kernel threads. Use case: balanced workload applications

95
New cards

Q: The ____ model multiplexes many user-level threads to a smaller or equal number of kernel threads

C) many-to-many model

96
New cards

Thread library

Provides programmer with API for creating and managing threads

97
New cards

Q: A ____ provides an API for creating and managing threads

C) thread library

98
New cards

Pthreads

A standard (IEEE 1003.1c) API for thread creation and synchronization; may be provided either as user-level or kernel-level; common in UNIX OSes (Linux & Mac OS X)

99
New cards

Q: A ____ uses an existing thread rather than creating a new one to complete a task

B) thread pool

100
New cards

Amdahl's Law

Identifies performance gains from adding additional cores to an application that has both serial and parallel components