processes Flashcards
When a task manager switches from executing one process to another, what is the primary purpose of saving and restoring the process context?
To ensure that the process can resume execution from where it left off when it is next scheduled to run
Process management means managing the context of a process (True/False)
True
what is a program (process slides)
A program is a passive set of instructions stored on a
secondary storage device, such as a disk
what is a process (process slides)
A process is an active execution of a program stored in
memory
– Program becomes process when loaded into memory
– Alt def: A process is an executing (i.e., running) instance of a
program
more precise definition of process (process slides)
A process is the context (i.e., information and data) maintained for an executing program
– A process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task
* Intuitively, a process is the abstraction of a physical processor
– Exists because it is difficult for the OS to otherwise coordinate many concurrent activities, such as incoming network data, multiple users, etc.
process management, what activities is the OS responsible for?
- *The OS is responsible for the following activities
– Process creation and deletion
– Process suspension and resumption
– Provision of mechanisms for: - Process synchronization
- Process communication
– Deadlock handling
process management, how does the OS correctly run multiple processes concurrently?
– What kind of information must be kept?
– What does OS have to do to run processes correctly?
– OS must be able to distinguish among different processes
* Multiple programs may be loaded into memory at same time
* Each process is assigned a unique, non-negative integral process ID, or PID
what does PID stand for? (processes slides)
The PID is a process ID number. Every process has a unique ID number, and it is allocated together with system resources such as memory.
What is the PID used for? (processes slides)
The system administrator uses the PID for changing the task
priority and ending tasks
how are processes logically organized?
Processes are organized in a hierarchical manner, just like
files and folders. So the child processes are nested under the
parent processes and so on.
what is the procedure when a process ends?
When a process ends, it is reported back to the parent
process. Its resources are freed and the pid is removed.
where are current processes stored?
- Information on current processes is stored in the /proc filesystem.
- This filesystem consists of kernel data that changes in real time (i.e., sensing and responding to external events nearly simultaneously). It is easy to extract the information contained therein using commands such as cat.
- Listing the contents of /proc with the ls command as follows will show numerous directories whose names consist only of numbers:
- ls /proc | less
What are the segments of memory in the process context?
- When a program loaded into memory, it is organized into the following segments of memory
– text contains the actual program code, or executable instructions
– data contains global and static variables initialized at runtime
– heap contains dynamic memory allocated at runtime
– stack contains return addresses, function parameters, and variables
what are the types of registers/register contexts?
– Program Counter (PC)
* Address of next instruction to be executed (may be in kernel or user memory space of this process)
– Processor Status Register
* Contains the hardware status at the time of preemption. Contents and format are hardware-dependent
– Stack Pointer (SP)
* Points to the top of the kernel or user stack, depending on the mode of operation at the time of preemption
– General-Purpose Registers
* Hardware dependent, R0, R1, R2, … eax, ebx, ecx…
what are some of the states in a process state machine?
- A process executes according to the following state machine:
– created: also “new”, initial state when created
– waiting: also “ready”, awaiting to be scheduled for execution
– running: actively executing instructions on the CPU
– blocked: unable to continue without an event occurring, e.g., I/O
– terminated: no longer running due to completion or being killed
user level context
code, data, stack heap
register context
R0, R1, … , PC, SP, etc.
system level context
Os resources. stuff like open files, signal related data structures, etc.
While a program is executing, the
process can be uniquely identified by
several elements, including:
- Identifier (PID)
- State
- Priority
- Program counter
- Memory pointers
- Context data
- I/O status information
- Accounting information
where is the process context stored?
– User level context is stored in memory
– Other context information is stored in a data structure called process control block (PCB)
* Contains other information that the OS needs to manage the
process
– Process status (running, waiting, etc.)
– Process priority
– …
– The OS has a process control block table
* For each process, there is one entry in the table
Process Control Block (PCB)
Information associated with each process (also called task control block)
* Process state
– Running, waiting, etc.
* Program counter
– Location of instruction to execute next
* CPU registers
– Contents of all process-centric registers
* CPU scheduling information
– Priorities, scheduling queue pointers
* Memory-management information
– Memory allocated to the process
* Accounting information
– CPU used, clock time elapsed since start, time limits
* I/O status information
– I/O devices allocated to process, list of open files
CPU Scheduler (short-term scheduler)
– Selects which processes should be executed next and allocates the CPU
– Invoked very frequently (milliseconds)
Processes can be described as either
– I/O-bound
* Spends more time doing I/O than computations; many short CPU bursts
– CPU-bound
* Spends more time doing computations; few very long CPU bursts
Job Scheduler (long-term scheduler)
– Selects which processes to be brought into ready queue
– Invoked very infrequently (seconds, minutes)
– Controls degree of multiprogramming, the max number of processes accommodate efficiently
Maintains scheduling queues of processes
– Job queue
* Set of all PCBs in the system
– Ready queue
* Set of all processes residing in main memory, ready and waiting to execute
– Device queues
* Set of processes waiting for an I/O device
– Processes migrate among the various queues