Operating System Concepts Ch.3

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

1/80

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:51 PM on 6/10/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

81 Terms

1
New cards

[Compare]: Explain the key differences between a program and a process, and describe the main components that define a process's current state.

A program is a static set of instructions, while a process is the active execution of that program. The current state of a process is defined by its program counter (indicating the next instruction to execute) and the contents of the CPU registers (holding active data and instructions). This distinction is crucial because the operating system manages processes, not programs directly. Key Differences: - Program: Static, passive, a file on disk. - Process: Dynamic, active, an instance of a program in execution. Process State Components: - Program Counter: Points to the next instruction. - CPU Registers: Hold current data and instructions being processed.

2
New cards

A process that is ready to be scheduled by the CPU but is not currently executing is in which state?

Ready

3
New cards

What is the primary benefit of multithreading within a single process?

It enables a single process to perform multiple tasks concurrently.

4
New cards

Why is a context switch considered overhead by the operating system?

No actual user-level work is accomplished during the switch.

5
New cards

In UNIX systems, what is the primary function of the fork() system call?

To create a new child process that is a copy of the parent's address space.

6
New cards

When a process is waiting for an event, such as I/O completion, it is moved to which queue?

The wait queue

7
New cards

Which data structure is used by the operating system to store all the critical information about a process?

Process Control Block (PCB)

8
New cards

What information is typically found within a Process Control Block (PCB)?

Process state, program counter, CPU registers, and scheduling information

9
New cards

[Explain]: Describe the typical memory layout of a process, detailing the purpose of each section (text, data, heap, stack) and how they are used during program execution.

The memory space of a process is divided into four main sections: 1. Text (fixed): Contains the executable machine code of the program. 2. Data (fixed): Stores global and static variables. 3. Heap (dynamic): Used for dynamic memory allocation (e.g., using malloc or new). Memory is allocated and deallocated as needed during runtime. 4. Stack (dynamic): Manages function calls. Each function call pushes an activation record onto the stack, containing parameters, local variables, and the return address. When the function returns, its activation record is popped off. This structure allows for efficient management of code, data, and runtime execution needs.

10
New cards

[Case Study]: A user is running a word processor, a web browser with multiple tabs, and a music player. The operating system needs to manage these applications. Describe the role of the process scheduler, the ready queue, and the wait queue in managing these applications, and explain what happens when the number of applications exceeds the available CPU cores.

The operating system uses a process scheduler to manage applications (processes). When applications are ready to run, they are placed in the 'ready queue'. The process scheduler selects processes from this queue to execute on available CPU cores. If an application needs to wait for an event (like disk I/O for loading a file, or network data for a web page), it is moved to the 'wait queue'. If the number of ready applications exceeds the number of CPU cores, the excess applications remain in the ready queue, waiting for a core to become free. The scheduler will then perform context switches to give each process a slice of CPU time, creating the illusion of simultaneous execution. This waiting and rescheduling is a fundamental aspect of multiprogramming. Key Components: - Process Scheduler: Decides which process runs next. - Ready Queue: Holds processes ready for CPU execution. - Wait Queue: Holds processes waiting for an event (e.g., I/O).

11
New cards

What is the fundamental unit of work in a modern operating system, representing a program in execution?

A process

12
New cards

What is the role of the process scheduler?

To select processes from the ready queue for execution on CPU cores.

13
New cards

What is the primary function of the stack in a process's memory layout?

To manage temporary data for function calls.

14
New cards

Which section of a process's memory is primarily used for storing global variables?

The data section

15
New cards

What is the purpose of the wait() system call for a parent process?

To suspend its execution until one of its child processes terminates.

16
New cards

When a parent process creates a child process, what is typically inherited by the child?

The parent's privileges, scheduling attributes, and open files

17
New cards

Explain the four critical considerations when designing and implementing inter-process communication (IPC) using pipes. For each consideration, briefly describe its impact on the communication process.

When implementing pipes for IPC, four key considerations are: 1. Directionality: This determines if data flows in a single direction (unidirectional) or can be sent and received through the same pipe (bidirectional). Unidirectional pipes are simpler but less flexible, while bidirectional pipes offer more complex but versatile communication. 2. Communication Mode: If two-way communication is supported (bidirectional), this specifies how it occurs. Half-duplex means data can only travel in one direction at any given moment, requiring careful synchronization. Full-duplex allows simultaneous data transfer in both directions, offering higher throughput but potentially more complex implementation. 3. Process Relationship: This addresses whether the communicating processes need a pre-existing relationship, such as a parent-child hierarchy. Some pipe implementations (like Unix pipes) are designed for related processes, simplifying setup and security. 4. Network Capability: This determines if the pipes are limited to processes running on the same machine (local) or can extend across a network. Network-capable pipes add significant complexity related to network protocols, addressing, and reliability. Understanding these factors is crucial for selecting the appropriate pipe type and configuring it effectively for a given IPC task.

18
New cards

What is the primary function of the wait() system call concerning terminated child processes?

It retrieves the exit status of the child and allows the OS to release the process table entry.

19
New cards

What defines a zombie process in an operating system?

A terminated process whose parent has not yet invoked the wait() system call.

20
New cards

In direct process communication, what is a fundamental characteristic of the communication link?

It is exclusively associated with exactly two processes.

21
New cards

[Case Study]: A mobile application is experiencing performance issues due to low memory. Explain how the Android operating system might resolve this issue and why it wouldn't terminate processes randomly.

Android employs an 'importance hierarchy' for processes. When memory is low, Android terminates processes starting with the least important ones to reclaim resources. This prevents the termination of critical foreground applications or essential system services, ensuring a better user experience and system stability. It prioritizes keeping more important processes alive over less important ones.

22
New cards

What is the primary requirement for processes to communicate using direct communication?

They must explicitly name the sender or the recipient.

23
New cards

[Compare]: Contrast the synchronization behaviors of zero-capacity, bounded-capacity, and unbounded-capacity message queues in inter-process communication.

Zero-capacity queues enforce immediate synchronization; the sender blocks until the recipient receives the message, acting as a rendezvous point. Bounded-capacity queues have a finite size; the sender blocks if the queue is full, waiting for space. Unbounded-capacity queues have potentially infinite size, so the sender never blocks, as there is always space available. The key difference lies in when and if the sender is forced to synchronize with the receiver based on the queue's capacity.

24
New cards

How do traditional UNIX systems handle orphan processes?

The init process adopts the orphans and periodically calls wait() to clean them up.

25
New cards

[Compare]: Explain the key differences between a zombie process and an orphan process, including how each state is resolved.

A zombie process is a terminated process whose process table entry remains because its parent has not yet called wait(). It persists to hold the exit status. It is resolved when the parent calls wait(). An orphan process is a child process whose parent has terminated before the child. In UNIX-like systems, the init process adopts orphans and calls wait() to clean them up, preventing them from becoming permanent zombies. The key difference lies in the parent's action: zombies are due to the parent not calling wait() on a terminated child, while orphans are due to the parent terminating before its children are handled.

26
New cards

What is a key consideration when designing pipes that allows data to travel in both directions at the same time?

Full-duplex communication

27
New cards

What happens when a sender attempts to send a message to a process using a zero-capacity message queue?

The sender is blocked until the recipient successfully receives the message.

28
New cards

What is a key advantage of using the Message Passing model for Inter-Process Communication (IPC), especially in distributed systems?

It is generally easier to implement and suitable for processes on different machines.

29
New cards

The producer-consumer problem is often used to illustrate the importance of what concept in cooperating processes?

Mutual exclusion.

30
New cards

[Quick Exercise]: A parent process spawns three child processes. Child A completes successfully and exits with status 0. Child B encounters an error and exits with status 1. Child C is still running. The parent process then calls wait() once. What information does the parent receive, and what happens to the process table entries for Child A and Child B?

The parent process will receive the exit status of one of its terminated children. Since wait() is called once, it will likely retrieve the status for either Child A (status 0) or Child B (status 1), depending on which terminated first or system scheduling. After wait() is called, the process table entry for the child whose status was retrieved (either A or B) will be released. The other terminated child (if not yet waited upon) would remain a zombie, and Child C would continue running.

31
New cards

Which aspect of pipe implementation determines if processes must have a parent-child relationship?

Requirement for a process relationship

32
New cards

In mobile operating systems like Android, what is the primary reason for terminating existing processes?

To free up memory and other system resources when they are scarce.

33
New cards

What is the primary action of the exit() system call when a process terminates?

It requests the operating system to deallocate all resources allocated to the process.

34
New cards

In the producer-consumer problem, what is the critical synchronization issue that needs to be addressed?

Preventing the consumer from accessing empty buffer slots and the producer from overwriting unconsumed data.

35
New cards

What historical significance do pipes hold in the context of Inter-Process Communication (IPC)?

They were among the earliest IPC mechanisms developed for UNIX systems.

36
New cards

How does the Shared Memory model of Inter-Process Communication (IPC) typically achieve faster data exchange compared to Message Passing?

After initial setup, data reads and writes are treated as normal memory accesses, avoiding repeated system calls.

37
New cards

What is the fundamental requirement for cooperating processes to exchange data effectively?

Inter-Process Communication (IPC) mechanisms.

38
New cards

Consider a message queue with a finite length. What is the behavior of the sender if the queue is full?

The sender is blocked until space becomes available in the queue.

39
New cards

[Explain]: Describe the two primary Inter-Process Communication (IPC) models and explain why one might be preferred over the other in specific scenarios.

The two primary IPC models are Shared Memory and Message Passing. Shared Memory involves creating a region of memory accessible by multiple processes. Once set up, data exchange is fast as it uses normal memory accesses. It's preferred for exchanging large amounts of data between processes on the same machine. Message Passing involves processes explicitly sending messages to each other. It's generally easier to implement and better suited for distributed systems where processes might be on different machines, as it handles the complexities of network communication implicitly.

40
New cards

What is cascading termination?

A system behavior where the termination of a parent process automatically terminates all its child processes.

41
New cards

What are the two fundamental operations provided by a message passing facility for Inter-Process Communication?

'send()' to transmit messages and 'receive()' to accept them.

42
New cards

In a symmetric direct communication scheme, what action must both processes take?

Both the sender and the receiver must name each other.

43
New cards

What distinguishes an independent process from a cooperating process?

Independent processes do not share data with other processes, while cooperating processes can affect or be affected by others.

44
New cards

Under what condition can a parent process typically terminate another process?

By invoking an appropriate system call, usually when it is the parent of the target process.

45
New cards

[Compare]: Differentiate between independent and cooperating processes, and list at least two reasons why an operating system would support cooperating processes.

Independent processes do not share data or interact with other processes, operating in isolation. Cooperating processes can affect or be affected by other processes, often sharing data. Operating systems support cooperating processes for: 1. Information Sharing: Allowing multiple applications to access and work with the same data. 2. Computation Speedup: Dividing tasks into subtasks that can run in parallel on multiple cores. 3. Modularity: Structuring system functions into separate, manageable processes or threads.

46
New cards

When implementing pipes for Inter-Process Communication (IPC), which factor relates to the simultaneous flow of data in both directions?

Communication mode (half-duplex or full-duplex)

47
New cards

What principle does Android utilize when reclaiming resources by terminating processes?

It terminates processes based on an importance hierarchy, removing the least important ones first.

48
New cards

What is the consequence of using an unbounded-capacity message queue for a sender?

The sender will never be blocked when attempting to send a message.

49
New cards

What is the purpose of the integer status value returned by a terminating process?

To inform the parent process about the outcome of the child process's execution.

50
New cards

Why do applications using sockets need to define their own data structures or protocols?

Sockets only handle unstructured byte streams, requiring the application to organize the data.

51
New cards

When a client initiates a network connection, how is its port number determined?

The client's host machine dynamically assigns a port number.

52
New cards

What is the nature of data transmission between sockets?

An unstructured stream of bytes.

53
New cards

[Compare]: Explain the key differences between UNIX pipes and named pipes (FIFOs) in terms of their creation, persistence, and how they are accessed.

UNIX pipes (created with `pipe()`) are temporary, existing only for the lifetime of the processes that created them. They are accessed via two file descriptors (`fd[0]` for reading, `fd[1]` for writing) and are not visible in the file system. Named pipes (FIFOs, created with `mkfifo()`) are persistent files in the file system and can be accessed by unrelated processes using standard file operations (`open()`, `read()`, `write()`, `close()`) on their file path. They persist until explicitly deleted.

54
New cards

What is the purpose of well-known ports in network services?

They provide standardized, predictable addresses for common services, simplifying client connections.

55
New cards

[Explain]: Explain how Remote Procedure Calls (RPCs) can be used for both inter-process communication (IPC) on the same machine and for communication between distributed processes across a network, highlighting the abstraction they provide.

Remote Procedure Calls (RPCs) offer a high-level abstraction for communication, making it appear as if a local function call is being made, even when the actual execution happens on a different process or machine. 1. Local IPC: RPCs can be used between processes running on the same machine. This provides a more structured and easier-to-manage communication channel compared to lower-level mechanisms like pipes or shared memory, as the developer doesn't need to handle byte streams directly. 2. Distributed Communication: For processes on different machines, RPCs abstract away the complexities of network programming. Developers define functions to be called remotely, and the RPC framework handles the underlying socket communication, data serialization/deserialization, and network protocols. This makes building distributed applications significantly simpler. In essence, RPCs hide the low-level details of network communication (like IP addresses, ports, and byte streams) and inter-process communication, allowing developers to focus on the application logic.

56
New cards

Why are ordinary pipes in UNIX primarily limited to communication between parent and child processes?

Children inherit open file descriptors, including pipes, from their parent.

57
New cards

Besides distributed systems, in what other context can RPCs be effectively utilized?

As a form of inter-process communication (IPC) between processes on the same machine.

58
New cards

In the context of Remote Procedure Calls (RPCs), what is the role of parameter marshaling?

To convert data representations between client and server machines, ensuring correct interpretation.

59
New cards

When inter-machine communication is required on a UNIX system, what mechanism must be used instead of FIFOs?

Sockets

60
New cards

How does the `pipe(int fd[])` system call facilitate communication?

It returns two file descriptors, one for reading and one for writing.

61
New cards

What is the purpose of a client periodically re-sending an RPC call until it receives an ACK message?

To ensure the server receives the request exactly once, removing the risk of non-receipt.

62
New cards

How are named pipes (FIFOs) treated after their creation with `mkfifo()`?

As regular files that can be manipulated with standard file I/O system calls.

63
New cards

For bidirectional communication between a parent and child process in UNIX, how many ordinary pipes are typically required?

Two separate ordinary pipes.

64
New cards

In the context of Remote Procedure Calls (RPCs), how can a client establish a connection with a server port?

Through a predetermined, fixed port address known at compile time.

65
New cards

What is a key limitation of FIFOs (First-In, First-Out) regarding communication scope?

FIFOs can only facilitate communication between processes residing on the same machine.

66
New cards

What is the role of the file descriptors returned by the `pipe()` system call?

They allow processes to interact with the pipe using standard file I/O operations.

67
New cards

In UNIX systems, how is data flow managed in ordinary pipes?

Data flows unidirectionally from the write end to the read end.

68
New cards

How does a server prevent duplicate processing of RPC messages using timestamps?

It compares the incoming message's timestamp with a history of recently executed messages.

69
New cards

What is the function of the IP address 127.0.0.1?

It allows a computer to communicate with itself, referred to as the loopback address.

70
New cards

[Case Study]: A distributed file system (DFS) needs to allow multiple clients to read and write to files stored on a central server. Describe how Remote Procedure Calls (RPCs) can be used to implement the file operations (open, read, write, close) for this DFS, considering both client-server interaction and potential network issues.

In a DFS using RPCs, each file operation (open, read, write, close) would be implemented as a distinct remote procedure. A client application would use a client-side stub to invoke these procedures. For example, a 'write' operation would involve the client stub marshaling the file descriptor, buffer, and number of bytes to write, then sending this message to the server's RPC daemon. The server-side stub would receive the message, unmarshal the parameters, execute the actual file write on the server's storage, and then send a return status back to the client via its stub. To handle network issues like duplicates, timestamps can be used to ensure 'at most once' execution, and server acknowledgments (ACKs) combined with client retries can ensure 'exactly once' semantics for critical operations.

71
New cards

What system call is used to create a named pipe (FIFO) in UNIX?

mkfifo()

72
New cards

How do Remote Procedure Calls (RPCs) simplify distributed application development?

By abstracting the complexities of network communication.

73
New cards

What uniquely identifies a socket for network communication between distributed processes?

The combination of an IP address and a port number.

74
New cards

[Case Study]: A team is developing a distributed system where a central server needs to receive real-time sensor data from multiple client devices, and also send configuration updates back to these devices. The clients and server may be running on different machines. Which IPC mechanism is most suitable for this scenario, and why?

Sockets are the most suitable IPC mechanism for this scenario. Here's why: 1. Inter-Machine Communication: The requirement for clients and server to be on different machines immediately rules out ordinary pipes and FIFOs, which are limited to processes on the same host. 2. Bidirectional Communication: The need to send data from clients to the server (sensor data) and from the server to clients (configuration updates) requires bidirectional communication. While FIFOs offer bidirectional communication, they are restricted to the same machine. 3. Client-Server Architecture: Sockets are inherently designed for client-server architectures and network communication, identified by IP addresses and port numbers. Sockets provide a robust endpoint for communication across networks, allowing for the establishment of unique connections (IP address + port number) between distributed processes, fulfilling all the requirements of this scenario.

75
New cards

What is the primary reason ordinary pipes cannot be used for communication between unrelated processes or across different machines?

They rely on the inheritance of file descriptors, a mechanism exclusive to parent-child relationships.

76
New cards

[Explain]: Why is parameter marshaling essential in Remote Procedure Calls (RPCs), and how does it ensure reliable communication between client and server?

Parameter marshaling is essential in RPCs because sockets, which often form the underlying communication layer, only handle unstructured byte streams. Different machines may have different data representations (e.g., endianness, data type sizes). Marshaling converts the data from the client's representation into a standardized format before transmission and converts it back to the server's representation upon receipt. This process ensures that data is correctly interpreted by both the client and server, preventing communication errors and guaranteeing that the remote procedure receives the intended parameters.

77
New cards

What is the primary characteristic of ordinary pipes in UNIX regarding communication direction?

They are unidirectional.

78
New cards

How are return values from a remote procedure call transmitted back to the client?

Using the same message passing technique employed for sending the initial call and parameters.

79
New cards

[Compare]: Contrast the communication capabilities and limitations of ordinary UNIX pipes versus named pipes (FIFOs). Consider aspects like directionality, process relationships, and machine locality.

Ordinary pipes are unidirectional and restricted to communication between a parent process and its child processes. They are implemented as special files but do not persist in the file system. Named pipes (FIFOs), on the other hand, are created using mkfifo(), appear as regular files, allow bidirectional communication (though half-duplex, meaning one direction at a time), and can be used by any processes on the same machine, regardless of their parent-child relationship. They do not persist after the last process closes them. Key Differences: - Directionality: Ordinary pipes are strictly unidirectional. FIFOs are bidirectional (half-duplex). - Process Relationship: Ordinary pipes require a parent-child relationship. FIFOs can be used between any processes on the same machine. - Persistence: Ordinary pipes are transient. FIFOs persist as file system entries until removed. - Machine Locality: Both are limited to processes on the same machine.

80
New cards

What fundamental concept does the Remote Procedure Call (RPC) paradigm represent?

A method for invoking remote services as if they were local function calls.

81
New cards

What is the role of a matchmaker daemon in dynamic RPC port binding?

It receives the RPC name from the client and returns the correct port number.