processes Flashcards

1
Q

What is a process and what resources does it require during execution?

A

A process is a program in execution and requires resources such as CPU time memory and file I/O which are allocated during execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does a process differ from a program?

A

A program is a passive entity stored on disk while a process is an active entity with a program counter and associated resources in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain the concept of a system process and a user process?

A

System processes execute the OS’s code while user processes execute user code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe the memory layout of a process?

A

A process has a memory layout with sections for code data stack and heap.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the role of the program counter register in representing the state of a process?

A

The program counter register represents the address of the next instruction to be executed in the process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain the growth direction of the stack and heap?

A

The stack and heap grow towards each other and the OS ensures they never overlap.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the activation record?

A

Each time a function is called an activation record containing function parameters local variables and the return address is pushed onto the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

List and explain the possible states a process can be in?

A

New Ready Running Waiting Terminated. New: The process is being created. Ready: The process is waiting to be assigned to a processor. Running: Instructions are being executed. Waiting: The process is waiting for some event to occur. Terminated: The process has finished execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In what situations does a process transition from one state to another?

A

Processes transition states based on events like creation waiting for I/O completion of execution etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What information is stored in the Process Control Block (PCB)?

A

The PCB stores information such as process state process number program counter CPU registers CPU-scheduling information memory-management information accounting information and I/O status information.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does the PCB contribute to process management?

A

The PCB serves as the repository for all the data needed to start or restart a process along with some accounting data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why is the PCB necessary for restarting a process?

A

The PCB contains crucial information about the process and it’s necessary for restarting or resuming the process after it has been stopped or interrupted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the objective of multiprogramming and time sharing in process scheduling?

A

The objective of multiprogramming is to maximize CPU utilization by having some process running at all times. Time sharing aims to switch a CPU core among processes frequently to allow users to interact with each program while it’s running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain the concept of scheduling queues?

A

Scheduling queues are data structures used by the process scheduler to organize processes based on their states and priority levels.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of context switching in process scheduling?

A

Context switching is necessary when switching the CPU core from one process to another. It involves saving the current context of the running process and restoring the context of the process to be scheduled.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Differentiate between a program and a process?

A

A program is a passive entity stored on disk while a process is an active entity with a program counter and associated resources in memory.

17
Q

How is a new process created in UNIX using the fork() system call?

A

The fork() system call is used to create a new process in UNIX. The new process is a copy of the calling process.

18
Q

Explain the flow of execution after a fork system call?

A

After a fork() system call both the parent and child processes continue executing from the instruction following the fork().

19
Q

When does a process terminate?

A

A process terminates when it finishes executing its final statement and uses the exit() system call to request deletion.

20
Q

Describe the memory layout of a process?

A

The memory layout of a process includes sections for code data stack and heap. Code: Stores the executable instructions of the program. Data: Holds global and static variables. Stack: Manages function call information including parameters and local variables. Heap: Dynamically allocated memory during the program’s execution.

21
Q

What is the status of the current activity of a process represented by?

A

The status of the current activity of a process is represented by the value of the program counter register and the contents of the processor’s registers.

22
Q

What are the sizes of all the sections in the memory layout except the stack and the heap?

A

The sizes of all sections in the memory layout except the stack and the heap are fixed.

23
Q

What happens each time a function is called in terms of the memory layout?

A

Each time a function is called an activation record containing function parameters local variables and the return address is pushed onto the stack.

24
Q

How do the stack and heap grow in relation to each other and why is it important to ensure they never overlap?

A

The stack and the heap grow towards each other and the OS must ensure that they will never overlap to prevent data corruption and program instability.

25
Q

What is the difference between a program and a process?

A

A program is a passive entity sitting somewhere on disk while a process is an active entity with a program counter specifying the next instruction to execute and a set of associated resources.

26
Q

When does a program become a process?

A

A program becomes a process when an executable file is loaded.

27
Q

What happens each time a function is called in terms of the memory layout and this function is recursive?

A

Each recursive call creates a new activation record (stack frame) with its own set of local variables, parameters, return address, and other necessary information. The activation records are stacked on top of each other. Recursion continues until a base condition is met, and then the function starts returning, removing activation records from the top of the call stack until the initial call completes.

28
Q

Is the stack frame like an activation record?

A

Yes, the stack frame is essentially an activation record. It contains information about a function call, including local variables, parameters, return address, and other necessary data. Multiple stack frames are stacked in the call stack during the execution of a program.

29
Q

What happens when we call a recursive function?

A

Yes, that’s correct. The recursion creates new activation records for each recursive call. The process continues until the base condition is satisfied, and then activation records are removed from the top of the call stack during the return phase. Care should be taken to prevent stack overflow by considering the depth of recursion.