CS439 Midterm 1

5.0(2)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/139

flashcard set

Earn XP

Description and Tags

Me when I don't rember any of the Internet Service Providers nor have I accomplished the HomeWork elements

140 Terms

1
New cards

What is an operating system (OS)?

Software that manages a computer’s resources, making it easier to write and run applications efficiently

2
New cards

Why study operating systems?

To understand how computers work, manage complexity through abstractions, and learn about system design trade-offs.

3
New cards

What are the three main roles of an operating system?

Referee, Illusionist, and Glue.

4
New cards

How does an OS act as a referee?

It manages shared resources, ensures process isolation, and enables communication between processes.

5
New cards

How does an OS act as an illusionist?

It creates the illusion of resources through virtualization, such as virtual memory and processor time-sharing.

6
New cards

How does an OS act as glue?

It provides standard interfaces to hardware, simplifies application design, and facilitates resource sharing.

7
New cards

What are the key factors in evaluating an OS?

Reliability, Security, Portability, and Performance.

8
New cards

What defines an OS’s reliability?

Its ability to consistently perform as designed, minimizing technical errors and maximizing availability.

9
New cards

What is the importance of security in an OS?

It ensures data privacy, enforces security policies, and prevents unauthorized access or system compromise.

10
New cards

What is OS portability?

The ability of an OS to function across different hardware platforms without modification.

11
New cards

What are the three interfaces that define OS portability?

Abstract Machine Interface (AMI), Application Programming Interface (API), and Hardware Abstraction Layer (HAL).

12
New cards

What are key performance metrics for an OS?

Efficiency, fairness, response time, throughput, and predictability.

13
New cards
<p>you are my sweaty</p>

you are my sweaty

this is true king

14
New cards

What were the three main phases in the history of operating systems?

  • Expensive hardware, cheap humans

  • Cheap hardware, expensive humans

  • Very cheap hardware, very expensive humans

15
New cards

What was characteristic of Phase 1 (1945-1965) in OS history?

  • Single-user systems

  • Batch processing for efficiency

  • Overlapping I/O and computation

  • Introduction of multiprogramming

16
New cards

What was batch processing, and when was it used?

A system where user jobs were grouped into batches and processed sequentially (1955-1965).

17
New cards

What is multiprogramming, and why was it important?

Running multiple programs concurrently to maximize CPU usage; required memory protection and relocation.

18
New cards

How did interactive timesharing (1970-) improve computing?

Allowed multiple users to interact with a system simultaneously, enabling easier debugging and faster responses.

19
New cards

What are the key requirements for interactive timesharing?

More sharing, more protection, more concurrency, virtual memory, and rapid process switching.

20
New cards

Why did early personal computing systems eliminate multiprogramming?

To simplify the OS, but this led to problems with reliability as programs could crash each other.

21
New cards

What is the difference between parallel and distributed computing?

  • Parallel computing: Multiple processors in the same machine share resources.

  • Distributed computing: Multiple processors communicate over a network.

22
New cards

Why are parallel and distributed systems important?

They improve performance, increase reliability, and enable resource sharing.

23
New cards

How did the complexity of OSs evolve over time?

They grew significantly, from simple batch systems to complex multi-user and networked systems like Unix, Windows, and Linux.

24
New cards

What is a process?

A process is a program during execution, consisting of the program code and its execution state.

25
New cards

What are the key components of a process?

  • Code (program instructions)

  • Static data

  • Execution stack (call chain)

  • Heap (dynamically allocated data)

  • CPU registers (PC, SP, etc.)

  • OS resources (open files, PID, execution state

26
New cards

What are the three main states of a process?

Running, Ready, and Blocked.

27
New cards

What is the role of the Process Control Block (PCB)?

Stores execution state, program counter, stack pointer, register contents, memory information, open files, and user ID of a process.

28
New cards

What are the three main roles of an OS?

Referee (resource management), Illusionist (virtualization), and Glue (standardized interfaces).

29
New cards

What is dual-mode execution?

A mechanism where the CPU operates in either user mode (restricted access) or kernel mode (full access) for security and protection.

30
New cards

What are privileged instructions?

Instructions that can only be executed in kernel mode, such as directly accessing I/O, modifying OS memory, or halting the machine.

31
New cards

How does a CPU switch from user mode to kernel mode?

Through exceptions, interrupts, or system calls.

32
New cards

What is an interrupt vector?

A data structure used by the OS to determine the appropriate response when an exception, interrupt, or system call occurs.

33
New cards

What is a system call?

A request by a user-level process to execute a function in the kernel, such as read(), write(), or exit().

34
New cards

How does a process create a new process in Unix?

Using fork(), which creates a child process identical to the parent.

35
New cards

What does exec() do in Unix?

Overlays a process with a new program while keeping the same PID.

36
New cards

What is the purpose of wait()?

It makes the parent process wait for a child process to terminate and retrieve its exit status.

37
New cards

What is a zombie process?

A terminated process whose parent has not yet collected its status.

38
New cards

What is an orphan process?

A process whose parent has terminated before the child process finishes execution.

39
New cards

How does a process terminate itself?

By calling exit(), which deallocates resources and notifies the parent.

40
New cards

How can a parent process terminate a child process?

Using the kill() system call, which sends a signal to the specified process.

41
New cards

What are some common Unix signals used for process control?

  • SIGHUP: Hang up (parent process termination)

  • SIGKILL: Forcefully terminate a process

  • SIGCHLD: Sent to the parent when a child process terminates

42
New cards

What is the purpose of nice() in process management?

It adjusts the priority of a process to influence scheduling.

43
New cards

What is ptrace() used for?

Debugging, allowing one process to control another by setting breakpoints and examining memory/registers.

44
New cards

How does sleep() function in process management?

It suspends a process for a specified amount of time before resuming execution.

45
New cards

What are the five states in the process life cycle?

New, Ready, Running, Blocked, Terminated

46
New cards

What is multiprogramming?

A technique where multiple processes are in memory at once, overlapping I/O and CPU activities to improve utilization and throughput.

47
New cards

What is long-term scheduling?

It determines the degree of multiprogramming by controlling the number of jobs in primary memory.

48
New cards

When does the short-term scheduler execute?

  • When a process switches from running to blocking

  • When a process is created or terminated

  • When an interrupt occurs

49
New cards

What is the difference between preemptive and non-preemptive scheduling?

  • Non-preemptive: A process runs until it blocks or terminates.

  • Preemptive: A process can be interrupted and replaced by another process due to a timer or hardware interrupt.

50
New cards

What are the key criteria for evaluating scheduling policies?

CPU Utilization

  • Throughput

  • Turnaround Time

  • Response Time

  • Waiting Time

51
New cards

What are the goals of an ideal CPU scheduler?

  • Maximize CPU utilization and throughput

  • Minimize turnaround time, waiting time, and response time

  • Ensure predictability and fairness

52
New cards

How does First-Come-First-Served (FCFS) scheduling work?

Processes execute in the order they arrive and run until completion or blocking.

53
New cards

How does Round Robin scheduling work?

Each process runs for a fixed time slice before being moved to the back of the queue.

54
New cards

What is a context switch?

The process of saving the state of one process and loading the state of another.

55
New cards

What is Shortest Job First (SJF) scheduling?

A scheduling policy that selects the process with the least CPU time required.

56
New cards

How does the Multilevel Feedback Queue (MLFQ) scheduling work?

  • Uses multiple priority queues.

  • A job starts at the highest priority.

  • If it uses up its time slice, it moves to a lower priority.

  • If it blocks before the time slice ends, it moves to a higher priority.

57
New cards

How does the boot sequence of an OS work?

  • CPU loads the boot program from ROM (BIOS/UEFI).

  • Boot program checks hardware configuration.

  • OS kernel is loaded and initializes system structures.

  • System processes start, and the OS becomes ready for user programs.

58
New cards

What is a thread?

A thread is an abstract entity that executes a sequence of instructions within a process, also known as a "Thread of Control."

59
New cards

How do threads differ from processes?

  • Threads share the same address space, while processes have separate address spaces.

  • Thread creation is cheaper than process creation.

  • Communication between threads is easier than between processes.

60
New cards

Why do programmers use multi-threading?

  • To better represent the structure of tasks.

  • To improve performance by allowing computation and I/O operations to overlap.

  • To take advantage of multi-processor systems.

61
New cards

How does multi-threading improve a web server's performance?

It allows multiple client requests to be handled concurrently, reducing total processing time.

62
New cards

What is the most expensive to switch between: processes or threads?

Processes are more expensive to switch between because they require switching address spaces, whereas threads share the same address space.

63
New cards

What are the five states of a thread?

New, Ready, Running, Blocked, Terminated

64
New cards

What components do threads share within a process?

  • Address space

  • Global variables

  • Heap

65
New cards

What are the two main types of threads?

User-level threads and Kernel-level threads

66
New cards

What is a user-level thread?

  • A thread that the OS does not know about.

  • Managed by a thread library in user space.

  • Switching between threads does not require kernel intervention.

67
New cards

What is a kernel-level thread?

  • A thread managed by the operating system.

  • Requires system calls for creation, destruction, and synchronization.

  • Supports parallelism on multi-core/multi-processor systems.

68
New cards

What are the advantages of user-level threads?

  • Faster context switching (no kernel involvement).

  • Custom scheduling policies can be implemented.

  • No need for system calls when switching threads.

69
New cards

What are the advantages of kernel-level threads?

  • The OS can schedule individual threads, improving performance.

  • One thread blocking does not block the entire process.

  • Can run in parallel on multiple cores/processors.

70
New cards

How do user-level threads handle context switching?

  • Thread yields control voluntarily.

  • Thread library saves the current thread’s state.

  • Scheduler selects a new thread.

  • New thread’s state is loaded.

71
New cards

How do kernel-level threads handle context switching?

  • Thread blocks, is interrupted, or voluntarily yields.

  • Mode switch to kernel mode.

  • Kernel saves the thread’s state.

  • Scheduler selects a new thread.

  • New thread’s state is loaded.

  • Mode switch back to user mode.

72
New cards

What is the difference between independent and cooperating threads?

  • Independent threads have no shared state and are deterministic.

  • Cooperating threads share state, making them non-deterministic but allowing concurrency.

73
New cards

What are the four main flavors of thread implementations?

  • Single-threaded processes (one thread per process).

  • User-level multi-threading (threads managed in user space).

  • Kernel-level multi-threading (threads managed by the OS).

  • In-kernel threads (threads running within the OS itself).

74
New cards
<p>um I believe in us guys</p>

um I believe in us guys

yaaassss qweeen 🌟

75
New cards

What is a race condition?

A race condition occurs when multiple threads access shared data concurrently, and the final result depends on the timing of execution.

76
New cards

What are the four properties required for correctness in critical sections?

  • Safety – Only one thread in the critical section at a time.

  • Liveness – If no threads are in the critical section, a waiting thread must eventually enter.

  • Bounded Waiting – There is a limit on how long a thread waits before entering.

  • Failure Atomicity – The system remains consistent even if a thread fails inside the critical section.

77
New cards

What is mutual exclusion?

A principle ensuring that only one thread or process accesses a shared resource at a time.

78
New cards

What is a critical section?

A section of code that must be executed by only one thread at a time to avoid race conditions.

79
New cards

What is an atomic operation?

An operation that cannot be interrupted and runs to completion without interference from other threads.

80
New cards

What is a lock in concurrent programming?

A synchronization mechanism that ensures only one thread can access a shared resource at a time.

81
New cards

What are the two main lock operations?

  • Lock:Acquire() – Wait until the lock is free, then take it.

  • Lock:Release() – Free the lock and wake up any waiting threads.

82
New cards

What is busy waiting?

A situation where a thread continuously checks for a condition instead of sleeping, wasting CPU cycles.

83
New cards

What are the problems with busy waiting?

  • Wastes CPU time.

  • Causes priority inversion issues.

  • Not scalable for multiple threads.

84
New cards

How does disabling interrupts help with mutual exclusion?

It prevents context switches while a thread is executing its critical section, ensuring atomic operations.

85
New cards

Why is disabling interrupts not an ideal solution for locking?

  • It prevents other important system tasks from running.

  • It only works on a single CPU, not multiprocessor systems.

86
New cards

What is the Test-and-Set instruction used for?

An atomic operation used to implement locks by checking and setting a variable in one step.

87
New cards

What is the problem with using Test-and-Set for locks?

It leads to busy waiting, where threads constantly check for lock availability, consuming CPU resources.

88
New cards

What is priority inversion?

A situation where a high-priority thread is waiting for a lower-priority thread to release a lock, potentially causing delays.

89
New cards

What is a semaphore?

A synchronization primitive used to control access to a shared resource, supporting more general synchronization than locks.

90
New cards

What are the two atomic operations of semaphores?

  • Down() – Decrements the semaphore; blocks if the count is 0.

  • Up() – Increments the semaphore; wakes up waiting threads if necessary.

91
New cards

What are the two types of semaphores?

  • Binary Semaphore – Acts like a lock, with values 0 (locked) and 1 (unlocked).

  • Counting Semaphore – Tracks multiple available resources and allows multiple threads to proceed.

92
New cards

How can semaphores be used to solve the "Too Much Milk" problem?

By using a binary semaphore to ensure mutual exclusion when checking and buying milk.

93
New cards

When should semaphores be used instead of locks?

  • When multiple resources are available.

  • When threads need to coordinate their execution beyond simple mutual exclusion.

94
New cards

How do counted semaphores differ from binary semaphores?

Counted semaphores allow multiple threads to proceed if there are available resources, while binary semaphores only allow one thread at a time.

95
New cards

What does the Up() operation do in a semaphore?

It increments the semaphore value and wakes up a waiting thread if necessary.

96
New cards
<p>I wish I could be as smart as my king Gregory House</p>

I wish I could be as smart as my king Gregory House

I am cooked if you cannot tell. I will donate the remnants of my brain to my dear friends.

97
New cards

What is the Dining Philosophers problem?

N philosophers sit at a table with N chopsticks; each needs two chopsticks to eat and alternates between thinking, getting hungry, and eating.

98
New cards

What is deadlock?

Deadlock occurs when two or more threads are waiting for an event that only the other threads can generate.

99
New cards

How is deadlock different from starvation?

Starvation happens when a thread waits indefinitely for resources, but other threads are using them. Deadlock implies starvation, but not vice versa.

100
New cards

What are the four necessary conditions for deadlock?

  • Mutual Exclusion – At least one thread holds a resource in a non-sharable mode.

  • Hold and Wait – A thread holds a resource while waiting for another.

  • No Pre-emption – A resource cannot be forcibly taken away from a thread.

  • Circular Wait – A circular chain of waiting threads exists.