Lecture 4 - Processes Flashcards

1
Q

Why are processes useful?

A

Makes full utilisation of the CPU

If processes with multiprogramming didn’t exist then each job would have sole control of the computer until it terminated

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

What is a process?

A

The OS’s abstraction for execution, i.e. a process is a program being executed

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

What is a sequential process?

A

An address space (abstraction of memory) being executed by a single thread of execution (abstraction of cpu)

The unit of execution, the unit of scheduling, the dynamic execution context vs the static program

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

What 3 basic things does a process consist of?

A

Address space - instructions, data

CPU State - program counter, stack pointer, registers

OS Resources - open files, network connections..

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

What are the 4 areas of a process’s address space

A

Stack (dynamic mem)

Heap (dynamic mem)

Static data (data segment)

Code (text segment)

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

What data structure does the OS maintain to keep track of a process’s state?

A

Process Control Block (PCB) or process descriptor

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

What sort of information does a Process Control Block include?

A

Process ID, Parent ID, execution state, Program counter, Stack pointer, registers etc.

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

What is the first process created when a UNIX system starts up?

A

init

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

How are new processes created in UNIX?

A

fork() system call

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

How does the fork() syscall work?

A

creates and initialises new PCB (and kernel resources the same as the parent)

Initialises program counter, stack pointer to be the same

Copies the address space of parent to child.

i.e. duplicates the process

returns the child’s PID to the parent

returns 0 to the child

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

How can a different process be started?

A

First fork then exec()

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

What does exec() syscall do?

A

stops current process

loads program in arg0 into address space (overwrites existing image)

Initialises hardware context and args for new program

Place pcb onto ready queue

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

How does a process exit?

A

once finished executing, calls exit()

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

What does the exit() syscall do?

A

releases all resources

gets rid of most OS structures supporting the process

checks if parent is alive

if os, enters “zombie” state

otherwise dies

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

How does a parent process arrange to get the return value of a child

A

wait() syscall

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

How does the wait() syscall work?

A

Puts the parent to sleep until the child exits

When child calls exit(), OS wakes parent and returns value, and gets rid of the zombies

17
Q

What are the 3 process execution states?

A

ready: waiting to be assigned to a cpu (could run, but another process has the cpu)
running: executing on a cpu
waiting: aka blocked, waiting for event such as I/O completion or message from another process

18
Q

What are the state transitions in and out of the running state?

A

In: dispatch/schedule from ready state

Out: interrupt to ready state

terminate to terminated state

trap or exception to blocked state

19
Q

What are the state transitions in and out of ready state?

A

in: create process

interrupt from blocked state (e.g. I/O complete)

interrupt from running state (cpu scheduling)

out: dispatch/schedule to running state

20
Q

What are the state transitions in and out of blocked state?

A

in: trap or exception from running state
out: interrupt (event completed e.g. I/O)

21
Q

Draw the process state transitions

A
22
Q

What is a context switch?

A

When the cpu switches from executing one process to another

23
Q

What is involved in a context switch?

A

CPU saves old PCB

and loads new PCB

24
Q

What is the problem with context swtiches?

A

While CPU is performing them no useful stuff can happen

100% overhead