Processes and Threads Flashcards

1
Q

what is a process in relation to a program?

A

a program is a bunch of instructions on a strorage medium, a process is a unit of work being executed on a computer. a program is run as one or more processes

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

what functions of processes does an OS facilitate? (5)

A
  • creation
  • deletion
  • scheduling
  • communication
  • syncronisation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what are 5 states a process can be in?

A
  • new
  • ready
  • running
  • waiting
  • terminated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is a PCB?

A

a process control block is an OSs representation of a process, held in a table or list

allows OS to suspend a running process and later restore its state

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

what is a context switch?

A

switching the CPU between execution of processes. the context is the process state, stored in the PCB list or table. there is no useful work done while switching

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

what do parents and children share?

A

when forking, the child gets a copy of the address space and they share file handlers. they are identical apart from their pid

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

what do threads share?

A

Share file desc and process space, have their own stacks and registers, can write to each other’s variables. Can communicate easily via variables.

have their own registers and stack

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

what is overwritten when exec is called?

A

everything, except the process id and file descriptors

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

how can processes share memory?

A

shm_open and mmap(). creates shared memory in heap

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

why are threads useful?

A

a process has its own private address space and its inconvient for IPC and expensive to switch contexts

useful in a server handling incoming connections, or a word processer waiting for input

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