Unit 2 Flashcards

1
Q

SAQ 1 - A

Distinguish between a program and a process.

A

A program is static and an abstraction of the desired program behaviour. A process is the dynamic representation of a program, that is, it represents the program’s execution.

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

SAQ 1 - B

What are the key requirements for operating systems?

A

There are three key requirements for operating systems:
1 Keeping systems busy.
2 Keeping users productive (responsiveness).
3 Sharing resources between users and processes.

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

SAQ 2 - A

Why is compiled code typically not portable from one platform to another?

A

Compilation creates platform-dependent machine code, targeted at a particular processor, therefore it is not portable.

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

SAQ 2 - B

What is the difference between user mode and supervisor mode?

A

Certain processor instructions, known as privileged instructions, cannot be executed when the processor is in user mode. User programs run in user mode and request supervisor mode instructions, where necessary, via library calls.

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

SAQ 3 - A

What is the purpose of the system bus?

A

The system bus allows the processing unit to communicate with devices through their respective device controllers.

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

SAQ 3 - B

What is the relationship between registers, main memory, disk storage, and cache?

A

Registers are storage locations inside the CPU which hold a machine instruction and
the data that it works on during a fetch–execute cycle.

A cache is similar to main memory, but is smaller and can be accessed by the CPU much faster than normal main memory. It is therefore used to hold data that is likely to be frequently accessed by the CPU.

Main memory consists of the storage locations for holding machine instructions and
data that the CPU will transfer into its registers as part of the fetch–execute cycle.

Disk storage is a device attached to a computer that holds files and programs which must be loaded into main memory before they can be worked on or executed. It is a form of persistent (non-volatile) storage.

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

SAQ 3 - C

What is a machine code instruction?

A

A machine code instruction is the fundamental instruction that a CPU works with and executes without interruption.

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

SAQ 4 - A

What are the three software interfaces that link a user program to a device controller?

A
  1. the interface between the program and its runtime system (provided by library
    calls) ;
  2. the interface between the runtime system and the operating system (provided by
    system calls);
  3. the interface between the operating system and the device controller (provided
    by device calls).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

SAQ 4 - B

How does an operating system interface to a device, and what is the role of a device driver?

A

An operating system provides a high-level interface to hardware that hides the specific details of how each device is programmed. Within the operating system, it is the device driver for a particular device that knows how to interface with the device controller and translates high-level requests into lower-level interactions with the device.

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

SAQ 4 - C

What is a device controller
and what is its purpose?

A

A device controller has its own simple processor, memory and registers, so that it can execute in parallel with the CPU and provide two-way communication with a hardware device. The operating system interfaces with the device controller via a device driver making device calls.

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

SAQ 5 - A

What is an interrupt? What actions must an operating system take when an interrupt occurs?

A

An interrupt is a mechanism by which a device or software signals to the processor that some event has occurred. If the interrupt is of high enough priority, the processor must perform a context switch. The processor must then execute a routine to deal with the interrupt (such as transfer data to a device) before resuming the original process.

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

SAQ 5 - B

What are the advantages and disadvantages of handling devices by a polling scheme compared with an interrupt-driven approach? In what kinds of system does the application dictate the approach to be taken?

A

In a polling scheme every device is guaranteed to be served within a specified time, but prioritisation is difficult. In an interrupt-driven system, urgent requests can be dealt with very quickly by assigning priorities to types of request, but non-urgent requests may have to wait for a long time while more urgent requests are dealt with.
Interrupt-driven systems are preferable in interactive systems and real-time systems, which require immediate responses to critical events.

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

SAQ 5 - C

What happens if a user program attempts to execute a privileged instruction (via a system call)?

A

A supervisor call interrupt is generated. A context switch takes place to put the processor into supervisor mode and execute the interrupt handler. At this point the interrupt handler may decide to execute the user code or not. Subsequently the processor returns to running in user mode via another context switch.

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

SAQ 5 - D

Why is it useful to have a system of priorities associated with interrupts?

A

Prioritised interrupts enable the operating system to react more quickly to some events than others.

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

SAQ 5 - E

What are the advantages of using a buffer for communication?

A

A buffer can be used to smooth out differences in operating speeds of the sending and receiving processes or devices, so that communication is more efficient – given a large enough buffer neither the sending nor the receiving process (or device) will need to wait after depositing data in the buffer before proceeding with other work.

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

SAQ 6

What is a process descriptor and why is it needed?

A

A process descriptor is a data structure storing information about the context of a process in a form that allows the process to be paused and restarted later. Storing information about the context of a process is necessary because the system normally can execute only one process at a time. To keep the system busy and responsive, and to prevent processes from interfering with each other, we need to be able to pause and restart processes (in other words to perform context switching).

17
Q

SAQ 7

Under what circumstances will a process scheduler suspend a process?

A

Usually a process is suspended when it is Blocked and other processes might be made Runnable by being admitted, or by being activated from a Runnable Suspended state. However, a Runnable process may also be suspended according to scheduler priorities and the availability of other high-priority processes to run.

18
Q

SAQ 8 - A

Explain how the timer interrupt mechanism together with the process scheduler assists in achieving multitasking on a single processor

A

A timer interrupt can be used by a scheduler to decide points in time at which to apply a selection function, that is, to pre-empt a running process. This may result in a decision to allow a different process to run from the one currently running. At this point the scheduler can initiate a context switch to make the processor deal with another task until the next switch should take place.

19
Q

SAQ 8 - B

Why is a pre-emptive scheduling policy preferred in interactive systems?

A

To provide greater fairness and responsiveness to processes requiring interaction.

20
Q

Exercise 2 - A

Suppose that a context switch takes 10 milliseconds and that the quantum is set to 10 milliseconds. Why is this not an efficient value for the quantum? What would be better?

A

In 20 milliseconds, the most the CPU can do is one quantum and one context switch. This means it spends a large proportion (about half) of its time context switching. It may be better to have a larger quantum in this case. For example, if the quantum is set at 30 milliseconds, then in 40 milliseconds the CPU might have done one context switch and spent 75% of its time on executing a process.

21
Q

Exercise 2 - B

In the round robin scheme, what is the effect of using a very large quantum?

A

The responsiveness of the system will degrade as the size of the quantum gets larger and individual processes keep a hold on the CPU for longer, starving other processes of time to the point where it becomes noticeable that some processes are not responding.

22
Q

Exercise 2 - C

Suppose that the quantum is 1 millisecond and the time to context switch is 10 milliseconds. What is the effect?

A

As the size of the quantum drops below the length of time to perform a context switch, the CPU spends most of its time context switching. In this case, in 100 milliseconds the CPU will have done 9 context switches, and executed processes for only 10 milliseconds – it will thus have spent 90% of its time on context switching.

23
Q

Exercise 2 - D

Comparing the round robin scheduling algorithm and the FIFO algorithm, under what circumstances are these more or less equivalent?

A

When the quantum becomes large with respect to service times, most jobs will run to completion without pre-emption, so the round robin algorithm will approximate to a FIFO algorithm. For the example in the text, when the quantum is greater than or equal to 6, the two policies are the same.

24
Q

SAQ 9 - A

What is the difference between a thread and a process?

A

Threads (lightweight processes) are a unit of dispatching but not of resource management. Processes are a unit of both dispatching and resource management. In particular, threads share an address space (memory) through which they can communicate ‘cheaply’ as compared to processes. This is because when there is a context switch it is unnecessary to change resource information, thereby reducing the time taken for the switch. A heavyweight process has its own copy of all resources and so context switches have a larger overhead.

25
Q

SAQ 9 - B

What is a multithreaded operating system?

A

A multithreaded operating system is one that supports the execution of lightweight processes.

26
Q

SAQ 10

Assuming the same WhoAmI class shown earlier, how many threads does the following code create within the Java Virtual Machine?
public class ThreadTester2
{
public static void main(String[]args)
{
WhoAmI thread1 = new WhoAmI("Joe");
WhoAmI thread2 = new WhoAmI("Sue");
thread2.run();
thread1.start();
new WhoAmI("Bloggs").start();
}
}
A

This code creates three threads: the thread started by invoking main, the thread created by invoking start on the Thread object referenced by thread1, and the anonymous thread we passed the value “Bloggs” to. Invoking run on the Thread objectreferenced by thread2 does not create a new thread. The run method would be executed within the main user thread, like a normal method call, and would be completed before thread1.start()is invoked.
In addition, the Java Runtime will have created other threads, such as the garbage collection thread.