Chapter 2 Process Model Flashcards

1
Q

The process model

A

Conceptually, each process has its own virtual CPU. In reality, of course, each real CPU switches back and forth from process to process,

Uses multi-programming to switch very quickly between processes.

There is only one physical program counter, so virtual ones are loaded in memory.

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

Blueprint for a process

A

A program

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

A process is an activity that is actively being run.
It has:

A
  • Program
  • Input
  • Output
  • State

only 1 parent, but n children

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

Which 4 events cause a process to be created?

A
  • System initialization
  • A running process makes a system call
  • A user requests a new process
  • Initiation of a batch job
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In UNIX, there is only one system call to create a new process: ____. This call creates an exact clone of the calling process. After the ____, the two processes, the parent and the child, have the same memory image, the same environment strings, and the same open files. That is all there is. Usually, the child process then executes execve or a similar system call to change its memory image and run a new program.

A

fork

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

How can a process terminate? (2 voluntary, 2 involuntary)

A
  • Normal exit (voluntary)
  • Error exit (voluntary)
  • Fatal error (involuntary)
  • Killed by another process (involuntary)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the 3 process states?

A

Blocked - because the process can’t continue because it’s waiting on something else

Running - Using CPU now
Ready - run-able but temporarily stopped to let another process run

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

The lowest layer of a process-structure OS. It handles interrupts and scheduling. Above that layer are sequential processes.

A

OS Scheduler

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

____ _____ has one entry per process (array)

Entries are called Process Control Blocks
- Process state
- program counter
- stack pointer
- memory allocation
- status of open files
- accounting and scheduling info

This saves the state of the process whenever the state is changed so it can be restarted later if it is stopped

A

Process Table

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

This is an example of a ____ ___ ___

Process management
- registers
- program counter
- stack pointer
- process id
- CPU time used

Memory management
- pointer to text segment info
- pointer to data segment info
- pointer to stack segment info

File management
- root directory
- working directory
- file descriptors
- user/group ID

A

Processes table entry

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

____ _____ (fixed location at bottom of memory). It contains the address of the ISR (interrupt service routine).

An ______ _____ isthe memory location of an interrupt handler, which prioritizes interrupts and saves them in a queue if more than one interrupt is waiting to be handled.

A

Interrupt vector

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

What happens when a program is interrupted?

A

its registers are pushed onto the current stack

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

What happens to processes during an interrupt?

A
  • save registers in the process table entry
  • after the interrupt, the process returns to the exact state it was before
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

very similar to processes, but they share an address space (and global variables). It’s a mini-process that shares data. Thread creation is 10-100 times faster than process creation.

A

Threads

They give almost no performance gain when all of them are CPU bound. They’re helpful when there is I/O that will block so other activities can continue. They are ALSO useful with multiple CPUs because real parallelism is possible.

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

What does a web server use to manage a pool of worker threads?

A

dispatcher thread

Note that threads can access the shared cache. These types of threads run in the user space because they are part of the application not the OS.

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

What are threads great for? What are 3 categories you could use threads for?

A

Threads are great when processing large amounts of data. Could have threads for

  • Input (i/o)
  • Processing (CPU)
  • Output (i/o)

This way the processing thread can go on while the slow I/o is being processed by other threads.

17
Q

Processes have a _____ _ _______, which has a program counter to keep track of which instruction to execute next

A

thread of execution

18
Q

What kind of items are these?
- program counter
- registers
- stack
- state

A

per-thread items

19
Q

What has these items?
- Address space
- Global variables
- open files
- child processes
- pending alarms
- signals and signal handlers

A

per-process items

20
Q

What kind of thing has these 4 states?
- Running
- Blocked
- Ready
- Terminated

A

Thread states

21
Q
  • Has local variables
  • One frame for each procedure called but not yet returned from. Also has a return address to use when a procedure call has finished.
A

Stack

22
Q

_____ have calls they can make like:

  • Thread_join (to wait on another thread to exit)
  • Thread_yeild (allow another thread to run on the CPU)
    Such a call is important because there is no clock interrupt to actually enforce multiprogramming as there is with processes.
A

Threads

23
Q

Used to write portable threaded programs. Provides functions related to thread management.

A

PThreads (POSIX Threads)

24
Q

Threads can yield because they are cooperative, but ___ do not. Because they are fiercely competitive and each wants all the CPU time it can get.

A

processes

25
Q

Benefits of Threads managed in user space

A

Can be used on OS’s that don’t support threads

Faster to create threads

26
Q

What does a process contain? (6 things)

A

Address space (memory location where it can read/write)
Executable program, data, and its stack
Registers, program counter, stack pointer
Open files
Related processes
Outstanding alarms

27
Q

A built-in bash command that is used to execute a command when the shell receives any signal is called `trap. It can respond to signals.

A

Trap