Process Management: Processes

5.0(1)
studied byStudied by 5 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/57

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

58 Terms

1
New cards
what is multiprogramming?
* a form of parallel processing where several programs run at the same time on a uniprocessor system.


* because there is only one processor, there is no true simultaneous execution of different programs. Instead, the operating system executes part of one program, then part of another, etc. (pseudo-parallelism.)
* To the user, it appears that multiple programs are executing at the same time
2
New cards
what are other names for a process?
* in a batch system - job
* in a time shared system - user program/ task
* unit of work
3
New cards
what is a process?
a program being executed on an OS. the program is converted into an executable file, file is run and loaded to memory.
4
New cards
what is the difference between a process and a program?
process is an active entity as program counter specifies the next instruction to execute and has a set of resources. program is passive entity
5
New cards
how do processes use resources?
processes need resources (CPU time, memory, files, i/o devices) to accomplish task. resources allocated to process when created or when executed (by operating system)
6
New cards
how is a program/ executable file loaded into memory?
GUI = double click

command line = enter fine name in command line
7
New cards
what’s an example of a process that is an execution environment?
java virtual machine which executes as a program
8
New cards
what is a system?
collection of processes e.g. os processes execute system code/ user processes execute user code. different processes can execute concurrently.
9
New cards
how many threads can a process have?


* traditionally processes only contained 1 thread
* modern os can support processes with multiple threads
10
New cards
how many processes can a program spawn?


* one program can spawn multiple processes e.g. users running different copies of the same program
* 2 processes from same program have separate execution sequences e.g. same text section but different data, heap, stack sections
* one process can spawn other processes
11
New cards
what is the os responsible for during process and thread management?
\
* create + delete user and system processes
* schedule processes
* synchronisation, communication, deadlock handling → if processes not scheduled properly, deadlock occurs
* gives us tools to see which process are running as processes can run in the background
12
New cards
what is a process made of?
4 process components

\
text section

stack

data section

heap

\
0…Max denotes the total memory allocated for the process.
4 process components

\
text section

stack

data section

heap 

\
0…Max denotes the total memory allocated for the process.
13
New cards
what is the text section in a process?
program code and current activity status. current activity status is specified by the program counter value and contents of process registers.
14
New cards
what is the stack in a process?
temporary data saved as a function with parameters, return addresses and local variable
15
New cards
what is the data section in a process?
global variables
16
New cards
what is the heap in a process?
memory dynamically added to the process during runtime
17
New cards
what is a process state?
* representation of the process’s current activity.
* as process runs it changes state based on the current activity of the process.
* there are different states depends on the needs of the process
18
New cards
what are the possible process states?
5 states

\
new

running

ready

waiting

terminated
19
New cards
what is the new process state?
The process is being created (not executing)
20
New cards
what is the running process state?
Instructions are being executed.
21
New cards
what is the ready process state?
The process is waiting to be assigned to a processor.
22
New cards
what is the waiting process state?
The process is waiting for some event to occur (e.g. waiting for I/O device completion or reception of a signal).
23
New cards
what is the terminated process state?
The process has finished execution.
24
New cards
how many processes can be in each state at any given time


* only one process can be running at a time
* many processes can be ready or waiting at a time
25
New cards
how are processes represented by the OS?
PCB, Process Control Block
26
New cards
what is the process control block?
* where info is stored about a process
* needed so the OS has the info it needs to schedule and allocate
* PCB will vary from process to process
27
New cards
how does the PCB work?


* PCB updated every time a process changes state (e.g. normal state change, whenever the process stops running) so OS knows what the process is doing
28
New cards
what are the components of the process control block?
process state

program counter

CPU registers

CPU scheduling information

memory management information

accounting information

I/O status information

\
got 7 total components
process state

program counter

CPU registers

CPU scheduling information

memory management information

accounting information

I/O status information

\
got 7 total components
29
New cards
what is the process state in the PCB?
can be new, ready, waiting etc.
30
New cards
what is the program counter of the PCB?
indicates the address of the next instruction to be executed for this process. state needs to be saved if interrupt occurs so process can continue correctly afterwards
31
New cards
what is the CPU registers in the PCB?
* data stores
* the registers vary in @@number@@ and @@type@@, depending on the computer architecture. include
* accumulators
* index registers
* stack pointers
* general-purpose registers
* condition-code information
* state needs to be saved if an interrupt occurs so the process can continue correctly afterwards
32
New cards
what is the CPU scheduling information in the PCB?
information used for scheduling the CPU

e.g. process priority, *pointers to scheduling queues* (ready queue) and other scheduling parameters
33
New cards
what is the memory management information in the PCB?
information to manage memory

e.g. value of the base registers, limit registers, page tables or segment tables, depending on the OS used
34
New cards
what is the accounting information in the PCB?
information including

e.g. amount of CPU and time used, time limits, account numbers, process numbers
35
New cards
what is the I/O status information in the PCB?
information including

e.g. list of I/O devices allocated to a process, list of open files
36
New cards
what is the state diagram for process states and PCB?
shows how state can change during process lifecycle

\
since the state regularly changes that means the process state component in the PCB is also regularly updated to match

\
\[ memorise the diagram including the words on the arrows

new → ready = admitted

ready → running = scheduler

running → waiting = I/O or event wait

waiting → ready = I/O or event completion

running → ready = interrupt

running → terminated = exit
shows how state can change during process lifecycle

\
since the state regularly changes that means the process state component in the PCB is also regularly updated to match

\
\[ memorise the diagram including the words on the arrows

new → ready = admitted

ready → running = scheduler

running → waiting = I/O or event wait

waiting → ready = I/O or event completion

running → ready = interrupt

running → terminated = exit
37
New cards
how does the CPU switch from one process to another during an interrupt?
CPU switches from process to process very quickly without the user’s realising that they aren’t running in parallel

\

1. Process0 executes
2. interrupt occurs
3. saves state of process0 to PCB0
4. reloads the state of process1 from PCB1
5. after state is loaded and cpu + memory allocated process1 executes
6. same process to return control
CPU switches from process to process very quickly without the user’s realising that they aren’t running in parallel 

\

1. Process0 executes
2. interrupt occurs
3. saves state of process0 to PCB0
4. reloads the state of process1 from PCB1
5. after state is loaded and cpu + memory allocated process1 executes
6. same process to return control
38
New cards
how are processes scheduled in the operating system?
using schedulers and scheduling queues
39
New cards
why do we need to schedule processes?
\
* to maximise CPU during multiprogramming so some processes can run at all times.
* to allow time-sharing to occur = switching the CPU between processes frequently so that users can interact with each running program.
* multiprogramming only has a single cpu = never more than 1 process running at a time and other processes have to wait until the CPU is free and can be rescheduled
40
New cards
what does the process scheduler do?


process scheduler selects an available process (from a set of available processes) for the CPU to execute. there are many scheduling queues that a process can be put into based on how the scheduler allocates CPU time.
41
New cards
what are scheduling queues?
* lists of processes that allows the OS to keep track of the needs of different processes
* process scheduler picks relevant process from relevant queue and carry out relevant operation
* each queue has a queue header
* can have priority queues based on the different schedulers, not always FIFO
42
New cards
what are the different types of scheduling queues?
job queue

ready queue

I/O aka. device queue
43
New cards
what is the job queue?
consists of all processes in the system, processes are added to job queue the moment they ENTER the system
44
New cards
what is the ready queue?
processes that are in the ready state and reside in main memory.

* ready queue header contains pointers to the first and last PCB in the list.
* each PCB has a pointer that points to the next PCB in the ready queue
processes that are in the ready state and reside in main memory. 

* ready queue header contains pointers to the first and last PCB in the list. 
* each PCB has a pointer that points to the next PCB in the ready queue
45
New cards
what is the I/O queue?
list of processes that are waiting for an I/O device (as a process might need to use an I/O device that is already being used by another process). each device has it’s own device queue
 list of processes that are waiting for an I/O device (as a process might need to use an I/O device that is already being used by another process). each device has it’s own device queue
46
New cards
how is process scheduling represented?
queueing diagram

* each box is a queue
* each circle is a resource that serve the queues
* arrows show the flow of processes in the system
* blue text shows the process state
queueing diagram

* each box is a queue
* each circle is a resource that serve the queues
* arrows show the flow of processes in the system
* blue text shows the process state
47
New cards
how does the process state, PCBs and OS queues work together to schedule processes?
relates to the process state diagram

* new process is put into ==ready queue== and waits until selected for execution or dispatched.
* when CPU has been allocated to the process, process leaves ==ready queue== and is in running state
* in running state the process can
* process issues I/O request and be put into ==device queue==, waiting state
* process creates new child process and waits for child to terminate, waiting state
* process is forcibly removed from CPU due to interrupt, waits for inturrpt to finish and moves straight into ==ready queue==, ready state
* after waiting state, process returns back to ==ready queue==, ready state
* cycle between \[ready, running, waiting\]
* process can repeat cycle until it terminates. when it terminates it is removed from all queues and PCB and resources are deallocated meaning PCB no longer exists, terminated state
relates to the process state diagram

* $$new$$ process is put into ==ready queue== and waits until selected for execution or dispatched.
* when CPU has been allocated to the process, process leaves ==ready queue== and is in $$running$$ state
* in $$running$$ state the process can
  * process issues I/O request and be put into ==device queue==, $$waiting$$ state
  * process creates new child process and waits for child to terminate, $$waiting$$ state
  * process is forcibly removed from CPU due to interrupt, waits for inturrpt to finish and moves straight into ==ready queue==, $$ready$$ state
* after $$waiting$$ state, process returns back to ==ready queue==, $$ready$$ state
* cycle between \[ready, running, waiting\]
* process can repeat cycle until it terminates. when it terminates it is removed from all queues and PCB and resources are deallocated meaning PCB no longer exists, $$terminated$$ state
48
New cards
how are processes stored on a batch system?
Often, in a batch system, more processes are submitted than can be executed immediately These processes are spooled to a mass-storage device (typically a disk), where they are kept for later execution
49
New cards
what are the different types of schedulers?


OS has 2 types of schedulers:

* short term scheduler/ CPU scheduler
* long term scheduler/ job scheduler
50
New cards
what is the short term scheduler?
* Selects which process should be executed next and allocates CPU (running)
* Sometimes the only scheduler in a system
* invoked frequently (milliseconds)
* must be fast as currently executing I/O bound processes may run a v short time before waiting for I/O, so a new process needs to be ready to execute to not waste CPU
51
New cards
what is the long term scheduler?
Selects which processes should be brought into the ready queue

* invoked infrequently (seconds, minutes) and may be slow
* The long-term scheduler controls the degree of multiprogramming (number of processes in memory). stable multiprogramming degree = average rate of processes crated = average rate of processes departing the system
* to keep stable multiprogramming degree long term scheduler might only invoke when process leaves the system and can take longer to decide which process to select next
52
New cards
what factors makes it difficult for the OS scheduler to schedule processes?
ensure it is @@load balancing@@ -

* want to use resources as efficiently as possible
* not all processes do the same amount of work or have the same needs (some need more CPU time than others, more calculations, more use of I/O)
53
New cards
what are the 2 main types of processes?
I/O bound processes

CPU bound processes
54
New cards
what are I/O bound processes?
spends more time doing I/O than computations, many short CPU bursts
55
New cards
what are CPU bound processes?
spends more time doing computations; few very long CPU bursts
56
New cards
what mix of processes should the long-term scheduler select and why?
Long-term scheduler should select a good process mix of I/O bound and CPU bound processes otherwise system will be unbalanced and lesser performance



* if all are IO bound, ready queue will be empty and short term scheduler has nothing to do
* if all are CPU bound, IO queue will be empty and devices unused
57
New cards
what is another type of scheduler used by time sharing systems?
medium term scheduler
58
New cards
what is the medium term scheduler?
* does swapping, where a process currently in memory is swapped out and swapped back in, reducing the degree of multiprogramming
* swapping may be needed to improve process mix and the current process might change it’s memory requirement and there’s not enough available memory to complete the process