Midterm Flashcards

1
Q

Name a general trend in going up or down the memory hierarchy?

A

speed is slower moving down the hierarchy
size is larger moving down the hierarchy
cost is less moving down the hierarchy

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

what is the relationship between the operating system and the kernel?

A

a kernel is a subset of the operating system

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

do system calls require kernel mode? why?

A

No, because system calls are like the communication between the operating system and the kernel mode.

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

Describe the relationship between a library procedure and a system-call.

A

Library procedure initiate a system call to access a memory address

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

Is a program a process?

A

only when it is running - process is a runnable program

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

How many processes can be run at a time on a single-processor?

A

1

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

Which of the following does each thread have a separate copy?

A
address space
global variables
* program counter
* registers
* stack
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Does an operating system have both user and kernel threads?

A

No, user will use in the application level and kernel will use operating system

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

Why do operating systems have user or kernel modes of execution?

A

to protect the operating system

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

What is a microkernel?

A

a small kernel

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

What is motivating factor behind the design decisions for a microkernel?

A

bugs

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

What is the UNIX equivalent to the CreateProcess( ) system call?

A

Fork( )

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

what will be displayed after executing the following code?
fork( );
fork( );
printf(“All done!\n”);

A

Prints all done four times

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

Name a service that the operating system provides.

A

Process scheduling
Resource usage
Accessing I/O devices
File system accesses/management

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

What is the stack of a thread?

A

parameters

local variables

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

The process table contains what kind of information?

A

process name and state
priority
registers
semaphores

17
Q

What are the major steps of a context switch?

A

Stopping one process and starting a new one

18
Q

Name 2 or more events that would cause a process to transition to the ready state?

A

one event is when the process has scheduled an interrupt. Another event is when one process has finished executing and the next process is ready to start executing

19
Q

What does the fork( ) system call do?

A

Its a process that creates a copy of itself.

20
Q

What does the execve( ) system call do?

A

Execve( ) is used to overlay a process image that has been created by a call from the fork( ) function.

21
Q

What does pthread_join( ) do?

A

pthread_join( ) waits for a specific thread to exit

22
Q

Name at least one benefit of using multithreaded programming?

A

You can run two processes at the same time instead of one at a time but the CPU will think it is only one process.

23
Q

What are the labels for the states that a process may be in?

A
A. creation
B. termination
C. ready
D. running
E. blocked
24
Q

What are the labels for the transitions between process states?

A
A. fork or create process
B. Scheduler
C. Exit
D. Scheduler
E. Event handling
25
Q

What process state transitions are not allowed and why?

A
  1. Blocked -> Running (has to go through ready)

2. Ready -> Blocked (can only be blocked if running)

26
Q

Explain the difference between an I/O-bound process and a CPU-process.

A

The difference between I/O-bound and CPU-bound processes are that the I/O-bound spends more time seeking I/O operations and CPU-bound spends more time performing computational work.

27
Q

Why should a web server not run as a single-threaded process?

A

A web server that runs as a single-threaded process can only be serviced with one client at a time. This could result in very long wait times for a busy server.

28
Q

What provides an interface to the services provided by an operating system?

A

System calls

29
Q

Write a code illustrating the typical usage of semaphores to protect a critical region.

A
#define N 100;
typedef int semaphore;
semaphore mutex = 1;
semaphore empty = N;
semaphore full = 0;
void producer(void) {
int item;
while true {
item = produce_item( );
down(&empty);
down(&mutex);
insert_item(item);
up(&mutex);
up(&full);
}
}