Module 1 - Fundamental concepts Flashcards

1
Q

What is the overall purpose of an operating system?

A

An operating system (OS) is system software that manages computer hardware and software resources and provides common services for computer programs. The OS controls the hardware and coordinates its use among the various application programs for the various user.

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

On a single (core) CPU, how can the operating system make several programs execute seemingly at the same time?

A

The objective of time sharing is user
interaction, to switch the CPU among jobs
so frequently that users can interact with
each program while they are running
seemingly at the same time.

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

What do we mean with operating system kernel?

A

The kernel is a computer program
that is the core of a computer’s
operating system, with complete
control over everything in the
system.

It is the part of the operating system that is running at all times. On boot, starts executing the first process such as init. It then waits for some event to occur.

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

What is the difference between a program, executable and process?

A

A program is a set of instructions which is in human readable format. A passive
entity stored on secondary storage.

An executable is a compiled form of a program including machine instructions and
static data that a computer can load and execute. A passive entity
stored on secondary storage.

A process ia an executable loaded into memory and executing or waiting. A process typically executes for only a short time before it either finishes or needs to perform I/O (waiting). A process is an active entity and needs resources such as CPU time, memory etc to execute.

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

What is the purpose of the stack?

A

To store temporary data such as function
parameters, local variables and return
addresses.

The stack grows from high addresses towards lower address.

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

Can processes share a single stack? Justify your answer

A

Processes do not share CPU stacks.

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

What are the names of the two modes?

A

User mode and Kernel mode.

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

What is the purpose of dual mode operation?

A

In order to protect the operating system from user processes.

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

How does dual mode achieve its purpose?

A

Dual mode operation place restrictions on the type and scope of operations that can be executed by the CPU.

Generally, when executing in kernel mode:
๏ All of the CPUs instructions are allowed.
๏ The kernel is allowed to access any memory address.

When executing in user mode:
๏ A subset of the CPUs instructions that would be dangerous for a user to execute are not allowed. For example instructions used to turn interrupts and exceptions on and off are not allowed.
๏ Only memory belonging to the process can be accessed.

This design allows the operating system kernel to execute with more privileges than user application processes.

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

In general, what does it mean for something to be synchronous or asynchronous?

A

Synchronous means happening, existing, or arising at precisely the same time.

Asynchronous simply means “not synchronous”.

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

In relation to the CPU, what does it mean for an event to be synchronous or asynchronous?

A

If an event occurs at the same instruction every time the program is executed with the same data and memory allocation, the event is synchronous. A synchronous event is directly related to the instruction currently being executed by the CPU.

On the other hand, an asynchronous event is not directly related to the instruction currently being executed by the CPU.

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

What is the purpose of exceptions and interrupts?

A

Interrupts and exceptions are used to
notify the CPU of events that needs
immediate attention during program
execution.

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

What are the differences between an exception and an interrupt?

A

Exceptions are internal and synchronous. They are used to handle internal program errors.

Overflow, division by zero and bad data address are examples of internal errors in a program.

Exceptions are produced by the CPU control unit while executing instructions and are considered to be synchronous because the control unit issues them only after terminating the execution of an instruction.

Interrupts are external and asynchronous. They are used to notify the CPU of external events.

Interrupts are generated by hardware devices outside the CPU at arbitrary times with respect to the CPU clock signals and are therefore considered to be asynchronous.

Examples:

Key-presses on a keyboard might happen at any time. Even if a program is run multiple times with the same input data, the timing of the key presses will most likely vary.

Read and write requests to disk is similar to key presses. The disk controller is external to the executing process and the timing of a disk operation might vary even if the same program is executed several times.

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

What is meant by CPU context?

A

At any point in time, the values of all
the registers in the CPU defines the
CPU context. Sometimes CPU state
is used instead of CPU context.

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

What steps are taken when handling an exception or interrupt?

A

‣ When an exception or interrupt occurs, execution transition from user mode to kernel mode.

‣ The cause of the interrupt or exception is determined.

‣ The exception or interrupt is handled.

‣ When the exception or interrupt has been handled execution resumes in user space.

But there is a problem. The exception/interrupt handler uses the same CPU (including the program counter and all other registers) as
the user processes.

When entering the exception/interrupt handler, values in all registers must be saved to memory before the kernel can use the registers.

Restoring cpu context:

Before resuming execution of a user process, the values of all registers must be restored using the values saved to memory earlier.

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

What is the overall purpose of the system call concept?

A

A user program requests service from the operating system using system calls.

In Mips, system calls are implemented using a special system call exception. Another name for exception is trap.

System calls forms an interface between user programs and the operating system.

17
Q

When requesting service from the operating system, why can a user process simply not use an ordinary function call to the kernel? Why must this be done using a system call and how is this different from an ordinary function call?

A

System calls implement checks to ensure that requests made by user programs are valid and that the programs have the necessary permissions to perform the requested operations.

An ordinary function call does not require support from the kernel to perform its requested operations.

18
Q

Why are exceptions important when implementing system calls?

A

Exceptions are the key to operating systems; they are the mechanism that enables the OS to regain control of execution and therefore do its job.

19
Q

What is meant by I/O?

A

Input and output: Any transfer of information between the ”brain” (CPU and main memory) and other parts of the system is considered I/O.

20
Q

What is special with I/O compared to normal execution?

A

I/O operations does not make use of the CPU but are handled by external devices.

21
Q

In multiprogramming a job can be in three states, name and explain the purpose of each state.

A

The job is currently executing on the CPU. At any time, at most one job can be in this state.

Ready:

The job is ready to run but currently not selected to do so.

Waiting

The job is blocked from running on the CPU while waiting for an I/O request to be completed.

22
Q

In multiprogramming, what happens when a job makes a request for I/O.

A

When a running job requests I/O, the job changes state from running to waiting.

Instead of idle waiting for the I/O request to complete, one of the ready jobs from memory is selected to execute on the CPU and have its state change from ready to running.

Eventually the the I/O request from the previous job will complete and the CPU will be notified by an interrupt.

The state of the waiting job will then change from waiting to ready.

23
Q

Explain step-by-step how the getc system call that allows a program to read a single character typed by a human user on the keyboard can be implemented.

Draw it out!

A
  1. Job 2 is ready to run and job 1 is running.
  2. Job 1 uses the getc system call to read a character from the keyboard.
  3. The system call uses a system call exception to enter the kernel.
    • The kernel saves the context (all register values) of job 1.
    • The kernel now knows that job 1 waits for input and changes its state from running to waiting.
    • The kernel restores the context of job 2.
  4. The kernel resumes execution of job 2. Job 2 and changes its state from ready to running.
  5. The human user presses a key on the keyboard.
  6. The key-press causes a keyboard interrupt which is handled by the kernel.
    • The kernel saves the context of job 2 and changes its state from running to ready.
    • The kernel knows that job 1 waits for the getc system call to complete.
    • The kernel restores the context of job 1 and changes its state from waiting to running.
    • The ASCII value of the pressed key is made available to job 1.
  7. The kernel resumes execution of job 1.
24
Q

Compared to getc, what steps must be added to implement the gets system call that allows a program to read a string of characters typed by a human user on the keyboard.

Draw it out!

A

https://os-assignments.github.io/v1/fundamental-concepts/system-call-design/