Made with ScholarlyMake flashcards like these from your own notes
Question:What is a process?
Answer:A process is a program in execution.
Question:What is a program?
Answer:A program is a passive entity stored on disk as an executable file.
Question:How does a program become a process?
Answer:A program becomes a process when its executable file is loaded into memory.
Question:Can you have one program and many processes?
Answer:Yes, one program can have many processes.
Question:What is temporary data storage in a process used for?
Answer:Temporary data storage in a process is used for invoking functions, function parameters, local variables, etc.
Question:What is dynamically allocated memory in a process?
Answer:Dynamically allocated memory is used for temporary data storage during the execution of a process.
Question:What are global variables in the context of a process?
Answer:Global variables are variables that are accessible throughout the entire process.
Question:What is a Process Control Block (PCB)?
Answer:A Process Control Block (PCB) stores all the information associated with each process, also called a task control block.
Question:What information is stored in a PCB?
Answer:Information stored in a PCB includes process state, process number (Process ID), CPU registers, program counter, CPU scheduling information, and memory management information.
Question:What does 'process state' refer to in a PCB?
Answer:Process state refers to the current status of the process, which can be running, waiting, etc.
Question:What is a Process ID?
Answer:A Process ID is a unique identifier assigned to each process.
Question:What does the PCB contain regarding CPU registers?
Answer:The PCB contains the contents of all process-centric registers, including CPU registers and program counter.
Question:What is CPU scheduling information in a PCB?
Answer:CPU scheduling information includes priorities and scheduling queue pointers.
Question:What memory management information is included in a PCB?
Answer:Memory management information includes the memory allocated to the process.
Question:How is a process represented in Linux?
Answer:In Linux, a process is represented by the C structure 'taskstruct'.
Question:What is the 'pid' in 'taskstruct'?
Answer:The 'pid' in 'taskstruct' refers to the process identifier.
Question:What does 'state' indicate in a 'taskstruct'?
Answer:The 'state' indicates the state of the process.
Question:What does 'timeslice' refer to in scheduling information of 'taskstruct'?
Answer:'timeslice' refers to the amount of time a process is allowed to run before being preempted.
Question:What does 'parent' signify in 'taskstruct'?
Answer:'parent' indicates this process's parent process.
Question:What does 'children' signify in 'taskstruct'?
Answer:'children' indicates this process's child processes.
Question:What does 'struct files' represent in 'taskstruct'?
Answer:'struct files' represents the list of open files for the process.
Question:What are the different states of a process during its execution?
Answer:1. New: The process is being created. 2. Ready: The process is waiting to be assigned to a processor. 3. Running: Instructions are being executed. 4. Waiting: The process is waiting for some event to occur. 5. Terminated: The process has finished execution.
Question:What is the difference between an IO bound process and a CPU bound process?
Answer:IO bound process spends more time doing IO than computations and has many short CPU bursts. CPU bound process spends more time doing computations and has few very long CPU bursts.
Question:What is a thread in the context of modern operating systems?
Answer:A thread is an entity within a process that can execute concurrently with other threads within the same process.
Question:What is context switching in operating systems?
Answer:Context switching is the process of saving the context of the old process and loading the saved context for the new process when the CPU switches to another process.
Question:What is the significance of context switch time?
Answer:Context switch time is an overhead for the system, as the system does no useful work while switching.
Question:What factors influence context switch time?
Answer:Context switch time is dependent on hardware support; some hardware provides multiple sets of registers per CPU, allowing multiple contexts to be loaded at once.
Question:What is represented in the PCB (Process Control Block)?
Answer:The context of a process is represented in the PCB.
Question:What are the operations on processes that the system must provide mechanisms for?
Answer:Process creation and process termination.
Question:What is the identifier given to every process called?
Answer:Process identifier (PID).
Question:How is a child process created?
Answer:A child process is created by a parent process using system calls.
Question:What is the term used for the parent process identifier?
Answer:Parent PID (PPID).
Question:What process is executed at system startup in newer Linux distributions?
Answer:init or systemd.
Question:What process identifier is assigned to init during system startup?
Answer:Process identifier 1.
Question:What does init do after startup?
Answer:Init launches all system daemons and user logins and becomes the parent of all other processes.
Question:What are the resource sharing options between a parent and child process?
Answer:1. Parent and children share all resources. 2. Children share a subset of parent’s resources. 3. Parent and child share no resources.
Question:What are the execution options for parent and child processes?
Answer:1. Parent and children execute concurrently. 2. Parent waits until children terminate.
Question:What are the address space sharing options for child processes?
Answer:1. Child is a duplicate of parent and has the same program and data as the parent. 2. Child has a new program loaded into it.
Question:What must the system provide mechanisms for regarding processes?
Answer:The system must provide mechanisms for process creation and process termination.
Question:What is the integer identifier given to every process called?
Answer:The integer identifier given to every process is called the process identifier (PID).
Question:What is the relationship between a parent process and a child process?
Answer:A parent process can create another process, known as a child process.
Question:How do parent processes create child processes?
Answer:Parent processes create child processes using system calls, which in turn creates other processes, forming a tree of processes or process tree.
Question:What additional identifier is stored along with the PID of a process?
Answer:Along with the PID of a process, its parent PID, termed as PPID, is also stored.
Question:What does 'init' do after system startup?
Answer:After system startup, 'init' launches all system daemons and user logins and becomes the parent of all other processes.
Question:What are the resource sharing options between a parent and child process?
Answer:1. Parent and children share all resources. 2. Children share a subset of the parent's resources. 3. Parent and child share no resources.
Question:What are the execution options for a parent and child process?
Answer:1. Parent and children execute concurrently. 2. Parent waits until children terminate.
Question:What are the address space sharing options between a parent and child process?
Answer:1. Child is a duplicate of parent and has the same program and data as the parent. 2. Child has a new program loaded into it.
Question:What is the purpose of the fork system call in Linux/Unix?
Answer:The fork system call is used to create a new process.
Question:Does the fork system call take any arguments?
Answer:No, the fork system call takes no arguments.
Question:What happens to the process that calls fork?
Answer:The process that calls fork becomes the parent process of the new child process created.
Question:What does fork return when the creation of the child process is unsuccessful?
Answer:Fork returns a negative value if the creation of the child process was unsuccessful.
Question:What is the relationship in terms of environment between the parent process and the child process created by fork?
Answer:The child process has the same environment as its parent, meaning it is an exact copy of the parent with only a different process ID.
Question:Do the child and parent processes share the same address space?
Answer:No, the child and parent processes have different address spaces.
Question:What happens after a new child process is created with fork?
Answer:Both the parent and child will execute the next instruction following the fork system call.
Question:How many processes including the parent are created with the following code: int main { fork(); fork(); fork(); return 0; }?
Answer:The number of processes created is 8 including the parent. (1 * 2 * 2 * 2 = 8)
Question:How do we distinguish between a child process and a parent process?
Answer:Fork returns a zero in the child process and returns the PID of the child process in the parent process.
Question:How can a process get its own PID?
Answer:Every process can query its own PID using the getpid() function.
Question:How can a process get its parent PID?
Answer:Every process can query its parent PID using the getppid() function.
Question:What is the return value of fork in the parent process?
Answer:Fork returns the PID of the child process in the parent process.
Question:What does the fork return in the child process?
Answer:Fork returns 0 in the child process.
Question:In the provided code, what is the type used to store Process ID?
Answer:pid_t is the type used to store Process ID.
Question:In the following code: 'if pid == 0 { printf("Child Process with PID %d\n", getpid()); } else { printf("Parent Process with PID %d\n", getpid()); }', what does pid == 0 signify?
Answer:pid == 0 signifies that the current process is the child process.
Question:What is the purpose of the 'fork' function?
Answer:The 'fork' function is used to create a new process by duplicating the calling process. It returns the child's process ID (pid) to the parent process and returns 0 to the newly created child process.
Question:What are pid1 and pid2 in the context of the process tree provided?
Answer:pid1 and pid2 represent the process IDs of the processes created by the fork calls in the code. Each process created will have its own unique pid.
Question:What is the output at Line A and why according to Question 4?
Answer:PARENT: value = 5 The parent and child processes have separate memory spaces, so changes made to the value in the child process do not affect the value in the parent process.
Question:What are the values of pid at lines A, B, C, and D as per Question 5?
Answer:A = 0 B = 2603 C = 2603 D = 2600 Line A (pid = 0): In the child process, fork() returns 0 to signify it's the child. Line B (pid1 = 2603): getpid() in the child returns its own PID, 2603. Line C (pid = 2603): In the parent, fork() returns the child's PID, 2603. Line D (pid1 = 2600): getpid() in the parent returns its own PID, 2600.
Question:What is the exec system call?
Answer:The exec system call used right after fork enables the child process to execute a different program than the one it inherits from its parent process.
Question:What is the act of a child process executing a different program than its parent called?
Answer:This act is referred to as an overlay.
Question:What is mentioned about exec functions?
Answer:There is a family of exec functions, all of which have slightly different characteristics.
Question:Where can one find more details about exec functions?
Answer:See the Linux manual for more details.
Question:What is the first step in process creation?
Answer:Process creation using the fork and Exec system calls.
Question:What happens to a process after executing the last statement?
Answer:A process is terminated.
Question:What are the two ways a process can terminate?
Answer:Implicitly using the return statement or explicitly using the exit system call.
Question:What happens to process resources after termination?
Answer:Process resources are deallocated by the operating system.
Question:How may a parent terminate the execution of child processes?
Answer:A parent may terminate the execution of child processes using the abort system call.
Question:What are some reasons a parent may terminate a child process?
Answer:Child has exceeded allocated resources or the task assigned to child is no longer required.
Question:What happens if a parent process terminates?
Answer:Sometimes the operating system does not allow a child to continue if its parent terminates.
Question:What does the OS do if the parent terminates?
Answer:The OS initiates cascading termination; all children, grandchildren, etc. are terminated.
Question:How can a parent know the child's exit status?
Answer:The parent can know the child's exit status using the wait system call.
Question:What does the wait system call return?
Answer:The wait system call returns status information and the pid of the terminated process.
Question:What does Unix/Linux maintain regarding processes?
Answer:Unix/Linux maintains a table of processes which contains the list of all processes running and includes the process status.
Question:What happens to a parent's entry in the process table if it terminates?
Answer:If a parent process terminates, its entry is removed from the table.
Question:When is a child's entry in the process table removed?
Answer:A child's entry is removed from the table only after the parent process invokes a wait.
Question:What is a zombie process?
Answer:If no parent is waiting and did not invoke wait, the process becomes a zombie.
Question:What is an orphan process?
Answer:If a parent terminates without invoking wait, the process becomes an orphan.
Question:What are the two types of processes within a system?
Answer:Processes within a system may be Independent or Cooperating.
Question:What can affect a cooperating process?
Answer:A cooperating process can affect or be affected by other processes, including sharing data.
Question:What are some reasons for cooperating processes?
Answer:Information sharing, computation speedup, modularity, and convenience.
Question:What is needed for cooperating processes to communicate?
Answer:Cooperating processes need interprocess communication (IPC).
Question:What are the two models of IPC?
Answer:The two models of IPC are Shared memory and Message passing.
Question:What is Shared memory in IPC?
Answer:An area of memory shared among the processes that wish to communicate, where the communication is under the control of the user processes, not the operating system.
Question:What are the advantages of Shared memory model?
Answer:It is used for sharing large amounts of data.
Question:What are the major issues with the Shared Memory model?
Answer:The major issues are synchronizing process actions when accessing shared memory.
Question:What does the operating system provide in the Message Passing model?
Answer:The operating system provides message passing capability.
Question:What is a drawback of Message Passing compared to Shared Memory?
Answer:Message Passing requires system calls for every message transfer and is therefore slower.
Question:What is an advantage of Message Passing?
Answer:It is simpler to set up and works well across multiple computers.
Question:What is the significance of IPC in operating systems?
Answer:IPC is crucial for enabling communication and synchronization between processes.