Week 4 Flashcards

Processes (42 cards)

1
Q

What is a process?

A

A program that is currently executing. Represents a single task the computer is doing

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

What hardware does the concept of a process help virtualize?

A

A CPU

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

What are the elements of a process?

A
  • one or more threads
  • an address space containing instructions and runtime data structures
  • zero or more open file handles
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 3 process execution states?

A
  1. Running
  2. Ready
  3. Blocked
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Scheduling

A

When a process is moved between running and ready.

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

What is exec()?

A

A syscall that starts a new process by TRANSFORMING the current process, which overwrites the current process with a new process.

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

What happens to any code after execve()?

A

Any code after execve() will not be run because it has been transformed.

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

What does exec() return?

A

It does not return if successful

Returns -1 on failure.

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

What exactly does exec() do?

A
  1. duplicates address space
  2. overwrite text segment
  3. reinitialize stack and heap
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is fork()?

A

a syscall used to CREATE a new process by creating a copy of the current running program. The original process is called the parent and the new process is the child.

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

How to tell the difference between the child and the parent after using fork()?

A

Child receives a value of 0.

Parent receives a value of the PID (process ID)

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

What is non-determistic execution?

A

For processes with the same PID the CPU scheduler decides which process runs first, and it can vary every time.

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

What is wait()?

A

A syscall that blocks the PARENT process until ONE of its children has finished executing.

Allows the OS to release resources associated with the child, which avoids ZOMBIES.

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

What is the difference between fork() and exec()?

A

Fork creates a new process by copying the original process.

Exec transforms a process by replacing the current process into a new process.

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

Example of using fork(), exec(), and wait() to do a command.

A
  1. Use fork() to split into 2 programs
  2. Use exec() on the child so it doesn’t affect the original process
  3. Use wait() in the parent code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Example of using fork in code.

A

if(fork() != 0){
PARENT CODE }
else {
CHILD CODE
}

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

Difference between program vs process

A

Program: a sequence of instructions stored in a file

Process: a program that has been loaded into memory for execution

18
Q

What is the Program counter (PC)

A

a register that indicates the next instruction to execute.

19
Q

What is signal()

A

a system call used to “catch” various signals like SIGINT (interrupts). Signals are used to help the process stop, continue, or terminate

20
Q

What is superuser?

A

Sometimes called the root, has permissions to control all processes and kill them.

21
Q

What is limited direct execution

A

Runs software directly on the hardware/CPU for high performance, but the OS still tries to maintain control through different tactics.

22
Q

What does the trap call in the program do?

A

Raises the privelege level and jumps into the OS.

23
Q

Where do we place the return from trap instruction?

24
Q

Where do we resume execution after the trap?

A

The Hardware.

25
What needs to happen before and after the program calls trap to raise privelege level?
Before: save current process into register After: load process back into register
26
What are some concerns of direct execution?
1. How to restrict operations of the program 2. How to stop the process from running
27
What is a trap table?
Kernel sets up a trap table at boot time to help the CPU know what kernel code to execute depending on if a trap happens. (with the help of trap handlers)
28
How does the OS know what system call to execute?
With the help of system call numbers, a number assigned to each system call.
29
What is the cooperative approach to gaining control of a process?
The OS waits for a process to make system calls such as yield() or perform an illegal operation so that it can regain control.
30
What is the non cooperative approach to gaining control of a process?
A TIMER INTERRUPT is used every milliseconds where the program is halted. An interrupt handler in the OS runs allowing it to regain control and decide whether it should stop the current process, start another one, or resume.
31
What is the MLFQ scheduler
(Multi-level feedback queue) places jobs into QUEUES, where each queue is assigned a PRIORITY LEVEL. The priority level changes as the scheduler learns more about the system.
32
5 General Rules of an MLFQ scheduler
1. if Priority(A) > priority(B), A runs. 2. if priority(A) = priority(B), A and B runs in RR fashion. 3. When a job first enters the system it is placed at highest pirority 4. When a job uses its time allotment at their current level, the priority is reduced 5. After a period of time S, move ALL jobs in the top most queue (BOOSTING)
33
What are some cons / issues of a MLFQ scheduler?
1. Starvation: too many interactive jobs running in the system that consume CPU time. long running jobs starve. 2. Gaming: doing something sneaky to trick the scheduler into giving a job more time than they actually need (such as an I/O operation after using 99% of it's time slice)
34
Pros of MLFQ?
- Good for MIXED workloads even without knowledge - Can handle changes over time and avoid starvation through boosting.
35
What is a proportional share scheduler
Instead of optimizing for turnaround / response time, attempts to give every job a fair share of resources. Examples: lottery & stride scheduling
36
What is lottery scheduling?
scheduler assigns lottery tickets to jobs and the job is scheduled when it wins the lottery. The more tickets a job has, the more chances it has to win and the more resources it is given.
37
Pros of lottery scheduling?
Simple to implement.
38
Cons of lottery scheduling?
Proportions are probabilistic and NOT deterministic. Meaning the scheduling is not guaranteed.
39
One way to implement a lottery scheduling
- Linked list of jobs and the alloted number of tickets. - Traverse the list, using a counter, and stop when the counter exceeds the winning number (chosen by a random number generator)
40
What is stide scheduling?
A deterministic fair-share scheduler. - Each job is given a STRIDE. Calculating by dividing a large number with the job's # of tickets. - When a job runs the scheduler increments a pass value, incremented by the STRIDE - The scheduler chooses to run the job with the LOWEST pass value.
41
What is pros of stride scheduling?
It is always deterministic, guarantees correct proportions.
42
Cons of strde scheduling?
It's difficult to add a new job to the system due to global state, unlike lottery scheduling.