Process Flashcards

1
Q

What is an OS’s task?

A

1) Abstraction: hide hardware details from applications/programmers/users
2) Resource Management: resources must be multiplexed in a fair way between applications/users
3) Protection: Different applications shouldn’t be able to disturb/manipulate each other
4) PROVIDING AN EXECUTION ENVIRONMENT FOR APPLICATIONS

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

Why is abstraction a central task of an OS

A
  • to hide implementation details of the hardware from the applications
  • make it easier to develop applications
  • increase application compatibility
  • improve reliability by taking away complexity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why is protection still as important although most devices run an OS used by a single user only?

A
  • protective measures such as the separation into user and kernel modes increases the reliability of the system
  • a buggy application might crash the whole system, leading to data loss
  • to protect user’s data from untrusted sources in today’s interconnectivity of the computers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the advantage of fixed-size integer types like uint32_t?

A

The normal int types have different sizes depending on the OS. The fixed-size types help writing portable code; code that works on multiple different systems without modification

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

Explain all functions of * and & operators

A
  • *: in front of a variable name declares that variable to be a pointer: *pointer1
  • *: in front of a pointer variable dereferences the pointer: return *pointer1
    -&: in front of a variable returns the address of that variable, which is a pointer: pointer2 = &notapointer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

User mode

A

-only non-privileged processor instructions can be executed

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

kernel mode

A
  • allow the execution of all instructions
  • some activities that control & manage the system as a whole may only be performed in kernel mode
  • it is needed to avoid other applications to use the system according to their own needs while negatively affecting other applications; by occupying the system resources as long as they need
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are privileged instructions and give examples

A

Instructions that
- manipulate control registers for memory translation
- disable or enable interrupts
- access platform devices
+Load and store control registers
+Halt processor
+Write model-specific registers
+Read time-stamp counter

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

Basic data types in C

A

-char: 1B
-short: 2B
-int: 4B
-long long: 8B
-float: 4B
-double: 8B

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

Global variables

A
  • live while the program runs
  • placed in the data segment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Local variables

A
  • accessible and valid only in the scope of the block/function in which they are declared
  • placed on the stack or in CPU registers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a process?

A

A process is a program in execution - an instance of a program
Each process is associated with a OS data structure called process control block (PCB) that holds all state information

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

Concurrency vs parallelism

A

Concurrency: Multiple processes on the same CPU
Parallelism: Processes truly running at the same time with multiple CPUs

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

What is direct execution and its problems?

A

Direct execution: Allow user process to run directly on hardware, OS creates process and transfers control to starting point
Problems:
- Process can harm each other
- Could read/write other process data
- Process could run forever
- Process could do something small

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

80:20 rule

A

Programs can see more memory than available:
80% of process memory idle, 20% active working set

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

What are three kinds of data

A
  1. Fixed size data items
  2. Data that is naturally free’d in reverse order of allocation
  3. Data that is allocated and free’d dynamically at random
17
Q

Fixed-size data and code segments

A
  1. BSS: variables that haven’t been initialized, the executable file typically contains the starting address and size of BSS, the entire segment is initially zero
  2. Data segment: initialized data elements
  3. Read-only data segment: constant numbers and segments
18
Q

Typical process address space layout

A

OS: Addresses where the kernel is mapped
Stack: Local Variables, function call parameters, return addresses
->

<-
Heap: Dynamically allocated data (malloc)
BSS: uninitialized data
Data: initialized data
RO-Data: Read-only data, strings
Text: Program, machine code

19
Q

Processes vs threads

A

thread -> lightweight process
an execution stream that shares an address space
multiple threads within a single process
(multiple stacks within the same address space)

20
Q

What are three occasions that invoke the kernel and switch to kernel mode?

A

-Syscalls: user mode process requires higher privileges
- interrupts: external device sends a signal to the CPU
- exceptions: CPU realizes a notable condition

21
Q

types of syscalls

A
  • process control
  • memory management
  • file management
  • device management
  • communication
  • information maintenance
  • system management
22
Q

Trap instruction

A

The trap instruction switches the CPU to kernel mode and enters the kernel in the same predefined way for every syscall.
It is a procedure call that synchronously transfers the control

23
Q

System Call Handler

A
  1. Saves registers
  2. Reads parameters that were passed by the caller
  3. Checks parameters
  4. Checks if the process has permission to perform the requested action
  5. Performs the requested service on behalf of the process
  6. Returns to the caller with a success or error code
24
Q

What are possible events that cause processes to be created?

A
  1. System initialization
  2. Process creation syscall issued by a running process
  3. User request to create a new process
  4. Initiation of a batch job
25
Q

What test does the kernel perform when receiving the address of a buffer as a syscall parameter?

A

The kernel ensures that the address lies within the user address range. That way, the user can’t fool the kernel into overwriting its own data structures or leaking critical system private information to the user process.

26
Q

Program vs process

A

Program: Passive entity, just a file on disk
Process: Active entity, has an execution context

27
Q

What is a zombie and how to prevent it

A

When a child process terminates, the parent may want to know the child’s exit status. To make this possible a stub of the child will stay in the process table after termination as a zombie. The parent needs to collect the exit status of the terminated processes with the wait() or waitpid() syscalls to free the zombies.

28
Q

What is the context of a process? Name its properties.

A

The context is made up of properties that identify the current runtime state of a process.
- General purpose registers, Instruction Pointer, Stack pointer
- Process state
- Process priority
- Unique process ID
- Open files
- Network connections
- Security credentials

29
Q

Single- vs multiprogramming

A

Single: allows only one process to run at a time, no overlapping on the CPU so the CPU would be idle up to 50% of the time

Multi: enables n > 1 processes to execute concurrently, sharing the physical resources

30
Q

CPU-bound and I/O-bound processes

A

CPU: rarely invokes I/O-operations, not very likely to block

I/O: perform only short computations between I/O jobs, expected to block often

31
Q

Kernel entries can be classified as voluntary/involuntary and synchronous/asynchronous. Associate the kernel entries.

A
  1. Interrupts: involuntary & asynchronous: the interrupted thread didn’t call for the interrupt or didn’t specify when the interrupt should occur; the activity that raised the interrupt executes independently of the current thread
  2. Exceptions: involuntary & synchronous: the application caused the event while executing, a specific instruction triggered the kernel entry synchronously with the program’s execution; the kernel entry is a side-effect rather than a desired action
  3. Syscalls: voluntary & synchronous: the kernel entry is caused by the execution of a specific instruction; the whole purpose of these instructions is to enter the kernel
32
Q

How to pass parameters to the kernel when performing a syscall?

A

-registers
-stack
-main memory + location in register

33
Q

Process states

A

-new: it has been created but never run
-ready: it is waiting to be assigned to a processor
-running: instructions are currently being executed
-waiting: it is waiting for some event to occur
-terminated: it has finished execution (zombie state)