Processes and threads Flashcards

1
Q

How are threads and processes created?

A

Via system calls

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

What do Processes and Threads cause a need for in a system?

A

Virtual memory and protection

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

How does the OS deal with processes and threads?

A

OS schedules and concurrently executes them. kernel manages processes.

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

What is a process?

A

A unit of work being executed on a computer

Program in execution

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

What functions does the OS have for processes?

A
  • Creation and deletion of processes
  • Scheduling processes on the CPU
  • Communication between processes
  • Synchronisation of >= 2 processes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Process structure

A
  • Stack
  • Heap
  • Data
  • Text
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a process control block?

A

OS representation of a process, held in a table or list. Allows OS to suspend and continue processes.

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

What does the scheduler include that allows for the extraction on information on a process?

A

struct task_struct

pid, state, open files contained.

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

What is context and how do we switch it?

A

Process state.

Save state of old process, load state of new process.

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

What are the disadvantages of context switching?

A

Pure overhead as no useful work can be done while switch is in progress.

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

How are processes created?

A

Create process system call (fork()). Calling process is parent and new processes are children.

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

How does the parent/child process affect child nodes

A

Program: Same as parent or different

Resource sharing: Shared, partially shared or not shared.

Execution: Concurrently or waiting to finish

Address space: Copy of parent’s or completely new.

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

How are processes terminated?

A

Exit system call by process itself or parent can kill child process.

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

What is cascading termination?

A

When parent process terminates, so to do all children.

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

What is an orphan process?

A

On parent crash, process is adopted by the init process or terminated.

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

What is a Daemon?

A

Services, intentionally orphaned. Run background tasks.

17
Q

What is a zombie process?

A

Process finished but parent hasn’t read return code.

18
Q

What does fork do?

A

Create child with copy of parent’s address space, resources of parent also available to child.

19
Q

What happens when fork returns?

A

Returns twice, parents get pid of child and child gets 0

20
Q

How do we change the program run by a child process?

A

exec(pid, new_program, [parameters], NULL).

21
Q

What happens in the process when exec occurs?

A

PID is retained, as are open file descriptors.

Overwritten: text, stack, heap and data

22
Q

How is sharing memory between processes possible?

A

shm_open(“name”, oflag)

Map it into process space using mmap()

23
Q

What are the characteristics of a thread?

A

Little private state:
Program counter, register set, stack

The rest is shared with other threads.

24
Q

Why use threads and not processes?

A

A process can have separate threads for control of different parts.

Saves overhead of process creation and context switching

Easy inter-thread communication

Utilises multi-processor architectures

25
Q

What are the different types of multi-threading models

A

Uses User level threads and kernel level threads

1:1, 1:M, M:N

26
Q

What are the characteristics of a user level thread?

A

Implemented in a user level thread library with no kernel support

27
Q

What are the characteristics of a kernel level thread

A

Kernel is thread aware and user level library provides thread api.

28
Q

How are threads created?

A

Using the clone system call. Must specify level of sharing.

29
Q

What are the different levels of sharing for threads?

A

Clone_FS: File-system shared

Clone_VM: Virtual memory shared

Clone_SIGHAND: Signal handlers shared

Clone_FILES: Open file table shared