Unit 2 Processes Flashcards

1
Q

What distinguishes the difference between a program and a process?

A

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

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

What are the key requirements for operating systems?

A

(Part 2) 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

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

A

(Part 2) Compilation creates platform-dependent machine code, targeted at a particular processor and so it is not portable.

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

What is the difference between user mode and supervisor mode?

A

(Part 2) 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

What is the purpose of the system bus?

A

(Part 2) 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

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

A

(Part 2) 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, butis smaller and can be accessed by the CPU much fastet 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

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

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

A

(Part 2) The three interfaces are:

  1. The interface between the program and its runtime system (provided by system 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

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

A

(Part 2) An operating system provides a high-level interface to hardware that hides the specific details of how each device is programmed. Within each 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

What is the device controller and what is its purpose?

A

(Part 2) 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

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

A

(Part 3) 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) befor resuming the original process.

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

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

A

(Part 3) In a polling shceme 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

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

A

(Part 3) 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 ode via another context switch.

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

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

A

(Part 3) 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

What are the advantages of using a buffer for communication?

A

(Part 3) A buffer can be used to smooth out differences in operating speeds of the sending and receiving processes of 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

What is a process descriptor and why is it needed?

A

(Part 4) 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 a time. To keep the system busy and responsive, and to prevent processes from interfering with each other, there is a need to be able to pause and restart processes (context switching).

17
Q

Under what circumstances will a process scheduler suspend a process?

A

(Part 4) 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

How does the timer interrupt mechanism together with the process scheduler assist in achieving multitasking on a single processor?

A

(Part 5) 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

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

A

(Part 5) To provide greater fairness and responsiveness to processes requiring interaction.

20
Q

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

A

(Part 5) In 20 milliseconds, the most the CPU can do is one quantum and one context switch - this means it spends a large proportion (around 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

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

A

(Part 5) 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

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

A

(Part 5) 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 and so will have spent 90% of time on context switching.

23
Q

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

A

(Part 5) 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.

24
Q

What is the difference between a thread and a process?

A

(Part 6) 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 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

What is a multithreaded operating system?

A

(Part 6) A multithreaded operating system is one that supports the execution of lightweight processes.

26
Q

What are the two ways to define a thread?

A

(Part 7) A thread can be defined extending the Thread class or by implementing the Runnable interface.

27
Q

When a thread is executing, does it always keep executing until it gets to the end of its code without interruption?

A

(Part 7) No, a thread is unlikely to keep executing until it comes to the end of its code. It is most likely that the thread will only have access to the CPU for a short part of its execution before it is stopped and another thread is given an opportunity to run.

28
Q

How do you tell the system that you want to set a thread running?

A

(Part 7) To set a thread running after creating an instance of a threaded class, the method start can be invoked.

29
Q

How would you typically want to define a thread by implementing Runnable rather than extending Thread?

A

(Part 7) There are many occasions when a threaded class will be inheriting from another class, for example JFrame. As Java does not allow multiple inheritance if these classes require threading the only way to do this is by implementing the Runnable interface.

However, it is generally best to implement Runnable when you do not require an inheritance relationship with Thread.

30
Q

How do you define, create, and start a thread using Runnable?

A

(Part 7) First implement the interface Runnable, which requires implementing the run method required by the interface.

Then create an instance of the Runnable class and create a new Thread object using the Thread constructor that takes a Runnable object as an argument.

The Thread object thus created can be started in the usual way, by invoking the start method.

31
Q

When would you want to create a daemon thread?

A

(Part 7) A daemon thread may want to be created when the thread is intended to run without intervention, or when it is safe for the virtual machine to exit whether or not the thread has completed running.

This is often the case for threads that do background work.

32
Q

What kind of thread is created by invoking main?

A

(Part 7) Invoking main creates a user (non-daemon) thread.

33
Q

Under what circumstances should a Java thread relinquish a processor? How could it do so?

A

(Part 7) A thread may initiate a context switch when it is waiting for an event or simply to allow other threads a chance to run, by invoking the yield method, or the sleep method.