Process Management: Processes

studied byStudied by 5 people
5.0(1)
Get a hint
Hint

what is multiprogramming?

1 / 57

flashcard set

Earn XP

Description and Tags

58 Terms

1

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

New cards
2

what are other names for a process?

  • in a batch system - job

  • in a time shared system - user program/ task

  • unit of work

New cards
3

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.

New cards
4

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

New cards
5

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)

New cards
6

how is a program/ executable file loaded into memory?

GUI = double click

command line = enter fine name in command line

New cards
7

what’s an example of a process that is an execution environment?

java virtual machine which executes as a program

New cards
8

what is a system?

collection of processes e.g. os processes execute system code/ user processes execute user code. different processes can execute concurrently.

New cards
9

how many threads can a process have?

  • traditionally processes only contained 1 thread

  • modern os can support processes with multiple threads

New cards
10

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

New cards
11

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

New cards
12

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.

<p>4 process components</p><p></p><p>text section</p><p>stack</p><p>data section</p><p>heap</p><p></p><p>0
Max denotes the total memory allocated for the process.</p>
New cards
13

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.

New cards
14

what is the stack in a process?

temporary data saved as a function with parameters, return addresses and local variable

New cards
15

what is the data section in a process?

global variables

New cards
16

what is the heap in a process?

memory dynamically added to the process during runtime

New cards
17

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

New cards
18

what are the possible process states?

5 states

new

running

ready

waiting

terminated

New cards
19

what is the new process state?

The process is being created (not executing)

New cards
20

what is the running process state?

Instructions are being executed.

New cards
21

what is the ready process state?

The process is waiting to be assigned to a processor.

New cards
22

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).

New cards
23

what is the terminated process state?

The process has finished execution.

New cards
24

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

New cards
25

how are processes represented by the OS?

PCB, Process Control Block

New cards
26

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

New cards
27

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

New cards
28

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

<p>process state</p><p>program counter</p><p>CPU registers</p><p>CPU scheduling information</p><p>memory management information</p><p>accounting information</p><p>I/O status information</p><p></p><p>got 7 total components</p>
New cards
29

what is the process state in the PCB?

can be new, ready, waiting etc.

New cards
30

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

New cards
31

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

New cards
32

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

New cards
33

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

New cards
34

what is the accounting information in the PCB?

information including

e.g. amount of CPU and time used, time limits, account numbers, process numbers

New cards
35

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

New cards
36

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

<p>shows how state can change during process lifecycle</p><p></p><p>since the state regularly changes that means the process state component in the PCB is also regularly updated to match</p><p></p><p>[ memorise the diagram including the words on the arrows</p><p>new → ready = admitted</p><p>ready → running = scheduler</p><p>running → waiting = I/O or event wait</p><p>waiting → ready = I/O or event completion</p><p>running → ready = interrupt</p><p>running → terminated = exit</p>
New cards
37

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

<p>CPU switches from process to process very quickly without the user’s realising that they aren’t running in parallel</p><p></p><ol><li><p>Process0 executes</p></li><li><p>interrupt occurs</p></li><li><p>saves state of process0 to PCB0</p></li><li><p>reloads the state of process1 from PCB1</p></li><li><p>after state is loaded and cpu + memory allocated process1 executes</p></li><li><p>same process to return control</p></li></ol>
New cards
38

how are processes scheduled in the operating system?

using schedulers and scheduling queues

New cards
39

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

New cards
40

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.

New cards
41

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

New cards
42

what are the different types of scheduling queues?

job queue

ready queue

I/O aka. device queue

New cards
43

what is the job queue?

consists of all processes in the system, processes are added to job queue the moment they ENTER the system

New cards
44

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

<p>processes that are in the ready state and reside in main memory.</p><ul><li><p>ready queue header contains pointers to the first and last PCB in the list.</p></li><li><p>each PCB has a pointer that points to the next PCB in the ready queue</p></li></ul>
New cards
45

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

<p>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</p>
New cards
46

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

<p>queueing diagram</p><ul><li><p>each box is a queue</p></li><li><p>each circle is a resource that serve the queues</p></li><li><p>arrows show the flow of processes in the system</p></li><li><p>blue text shows the process state</p></li></ul>
New cards
47

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

<p>relates to the process state diagram</p><ul><li><p><mark data-color="yellow">new</mark> process is put into <mark data-color="red">ready queue</mark> and waits until selected for execution or dispatched.</p></li><li><p>when CPU has been allocated to the process, process leaves <mark data-color="red">ready queue</mark> and is in <mark data-color="yellow">running</mark> state</p></li><li><p>in <mark data-color="yellow">running</mark> state the process can</p><ul><li><p>process issues I/O request and be put into <mark data-color="red">device queue</mark>, <mark data-color="yellow">waiting</mark> state</p></li><li><p>process creates new child process and waits for child to terminate, <mark data-color="yellow">waiting</mark> state</p></li><li><p>process is forcibly removed from CPU due to interrupt, waits for inturrpt to finish and moves straight into <mark data-color="red">ready queue</mark>, <mark data-color="yellow">ready</mark> state</p></li></ul></li><li><p>after <mark data-color="yellow">waiting</mark> state, process returns back to <mark data-color="red">ready queue</mark>, <mark data-color="yellow">ready</mark> state</p></li><li><p>cycle between [ready, running, waiting]</p></li><li><p>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, <mark data-color="yellow">terminated</mark> state</p></li></ul>
New cards
48

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

New cards
49

what are the different types of schedulers?

OS has 2 types of schedulers:

  • short term scheduler/ CPU scheduler

  • long term scheduler/ job scheduler

New cards
50

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

New cards
51

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

New cards
52

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)

New cards
53

what are the 2 main types of processes?

I/O bound processes

CPU bound processes

New cards
54

what are I/O bound processes?

spends more time doing I/O than computations, many short CPU bursts

New cards
55

what are CPU bound processes?

spends more time doing computations; few very long CPU bursts

New cards
56

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

New cards
57

what is another type of scheduler used by time sharing systems?

medium term scheduler

New cards
58

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

New cards

Explore top notes

note Note
studied byStudied by 91 people
... ago
5.0(2)
note Note
studied byStudied by 26 people
... ago
5.0(1)
note Note
studied byStudied by 15 people
... ago
5.0(1)
note Note
studied byStudied by 62 people
... ago
5.0(1)
note Note
studied byStudied by 16 people
... ago
4.0(1)
note Note
studied byStudied by 9 people
... ago
5.0(1)
note Note
studied byStudied by 15 people
... ago
5.0(1)
note Note
studied byStudied by 100 people
... ago
5.0(1)

Explore top flashcards

flashcards Flashcard (156)
studied byStudied by 7 people
... ago
5.0(1)
flashcards Flashcard (37)
studied byStudied by 7 people
... ago
5.0(2)
flashcards Flashcard (54)
studied byStudied by 31 people
... ago
5.0(1)
flashcards Flashcard (45)
studied byStudied by 88 people
... ago
5.0(2)
flashcards Flashcard (166)
studied byStudied by 6 people
... ago
5.0(1)
flashcards Flashcard (31)
studied byStudied by 7 people
... ago
5.0(1)
flashcards Flashcard (111)
studied byStudied by 169 people
... ago
5.0(2)
flashcards Flashcard (169)
studied byStudied by 13 people
... ago
5.0(1)
robot