Heavyweight processes &Threads Flashcards

1
Q

what are the 2 Process Types?

A

Heavyweight:
- The standard notion of a process when you start a program

Thread:
- Concurrency within a single “program”

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

What are Heavyweight Processes?

A

Processes are independent of one another:

  • Private address space
  • Private OS resources
  • Private PCB
  • Scheduled on it’s own by the OS

Managed directly by the OS

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

What are threads?

A
  • A set of related threads live within one heavyweight process

Within one heavyweight processes, the threads:

  • Share address space, PCB, resources (like the open file table)
  • Are scheduled together as the heavyweight process
  • Share the interrupt vector
  • Only have the basic hardware state as private components (instrction register, registers, condition code register, stack)

Often managed in user-space (context switches are faster)

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

Why have multiple types of processes?

A
 - Different context switch times
 - Availability of resources
 - Dedicated OS resources
 - Effect on CPU scheduling
 - I/O blocking behaviour
 - Types of communication
 - Protection of the processes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens when we run the fork() command on a process P?

A
  • fork() creates a copy (child) C of process P. C is then treated as independent of its parent process and allowed to execute whatever it must. All child processes created from P must be joined with it at the end of their run.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Give two examples of heavyweight process management.

A
  • System Start-up

- Shells

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. How do we typically create a thread?
  2. Where are threads created and managed? Do we use commands or function calls to manage them?
  3. Why must threads be run from the same executable?
A
  1. Threads are typically created within the userspace of the program. They require the inclusion of external libraries - such as pthreads.h - to work.
  2. Threads are created and managed within the userspace of the heavyweight process containing them. We manage them with function calls, such as pthread_create() and pthread_join().
  3. Threads are run from the same executable because there is only one primary executable within each heavyweight process, which itself must be the host to all threads within it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What can separate processes do?

A
  • Act independently
  • Do serial multitasking (hand off control between the 2 processes in a pre-determined way)

Cooperate:

  • one process can affect the other
  • Process execution is not pre-determined
  • Requires communication and synchronization
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why have cooperating processes?

A

Cooperating processes result in improved responsiveness and resource sharing between them. The operating system is thus taxed less, creating a more efficient system.

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

What are the three methods of interprocess communication?

A

Processes can communicate via:

  • Files
  • Shared Memory
  • Named Systems
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why is it atypical for processes to communicate via files?

A

Communication via files is a clumsy method of communication: It consumes many resources and assumes a shared-file system. This is an inefficient method of communicating, and rarely done.

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

Which type of process typically communicates through shared memory? What are some pros and cons to shared memory communication?

A

Communication via shared memory is typically done with threads. In general, this is a fast method of communication which is bi-directional (i.e. allows back-and-forth communication). However, this creates problems with mutual exclusion, atomicity, and execution of critical sections.

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

What are two types of communication via named systems? List three traits of one of these types.

A

Two types: Direct and Indirect.

Direct traits:

  • Can identify the peer process through address, PID, and OS construct.
  • Changing PID could damage or corrupt the process.
  • Data from one process is sent to a specific peer process
  • Communication can be:
  • –symmetric - where the sender and receiver must name each other for the communication to succeed, OR
  • –asymmetric - where only the sender needs to name the receiver for the communication to succeed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Message Passing Issues

A
  • Peer disappears
  • Messages are lost
  • Messages are scrambled
  • Messages arrive out of order

Risk:

  • Shared memory - low probability of these issues
  • On a shared computer - peer may disappear but the rest are improbable
  • across a network - anything can happen

Buffering:

  • None
  • bounded
  • unbounded

Method of transmission:

  • Pass by copy
  • pass by reference

Message Size:

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

Mapping threads to kernel threads.

A
  • A kernel thread is the basic unit of scheduling and process management seen by the kernel
  • Traditionally, one heavyweight process matches one kernel thread
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

the 3 multithreading models

A
  • many-to-one
  • one-to-one
  • many-to-many
17
Q

define a many-to-one thread model

A
  • All threads in one heavyweight process map to a single kernel level thread (All threads share the CPU time allocated to the kernel thread)
  • If the heavyweight process blocks then all the threads block
  • Can be managed completely in user space
  • Traditional / original view of threads
18
Q

define a one-to-one thread model

A
  • Each thread has it’s own kernel thread (allows for more concurrency)
  • if one thread blocks, the remaining threads can continue
  • Requires the intervention of the kernel to create threads or do context switches
  • usually limits the number of threads that can be created

eg. Windows XP and Linux don’t distinguish between threads and heavyweight processes

19
Q

define a many-to-many thread model

A
  • A set of threads share a set of kernel threads
  • Can have up to the number of kernel threads block before the whole
    heavyweight process blocks
  • Allows one heavyweight process to access multiple processors at
    once
  • Can create as many threads as we want; they just share CPU time
  • Hybrid model lets you bind a few threads directly to kernel threads
    while the others share a pool of threads