Section 1 & 3
Chapter 1
1.1 What are the three main purposes of an operating system?
- crontrol of user programs
- provide a kernel
- resource allocator
1.2 What are the main differences between operating systems for mainframe computers and personal computers?
Main frame dont need to worry so much about cpu bound processes hogging the processor, they dont need to provide a GUI
1.3 List the four steps that are necessary to run a program on a completely dedicated machine—a computer that is running only that program.
- reserve machine time
- load program into memory
- execute
- control and monitor the program
1.4 We have stressed the need for an operating system to make efficient use of the computing hardware. When is it appropriate for the operating system to forsake this principle and to “waste” resources? Why is such a system not really wasteful?
when a process is spinning, it may be more efficent to wait than to context switch
1.5 What is the main difficulty that a programmer must overcome in writing an operating system for a real-time environment?
processes must be completed on time, a good scheduling algorithm is needed
1.6 Consider the various definitions of operating system. Consider whether the operating system should include applications such as Web browsers and mail programs. Argue both that it should and that it should not, and support your answers.
OS designed for the masses, would prefure to have inbuilt browsers ect... since the user does not want to think about which is the best browser to use. However an OS for say a database would serve no benefit from having a browser.
1.7 How does the distinction between kernel mode and user mode function as a rudimentary form of protection (security) system?
Kenel mode allows for near unresticted control over resources, user mode does not allow this, processes should not be allowed to control resources since they could then provided them selves with too many resources, not allowing other processes to run.
1.8 Which of the following instructions should be privileged?
a. Set value of timer. \
b. Read the clock.
c. Clear memory. \
d. Issue a trap instruction.
e. Turn off interrupts. \
f. Modify entries in device-status table. \
g. Switch from user to kernel mode. \
h. Access I/O device. \
1.9 Some early computers protected the operating system by placing it in a memory partition that could not be modified by either the user job or the operating system itself. Describe two difficulties that you think could arise with such a scheme.
Sensitve data would have to be passed though unprotected memory.
1.10 Some CPUs provide for more than two modes of operation. What are two possible uses of these multiple modes?
COME BACK TO MEEE
1.11 Timers could be used to compute the current time. Provide a short description of how this could be accomplished.
A known time is set, such as the start of 1970, then a timer is started, by adding the number of seconds passed to the known time the computer will know the date. This could be achieved by a timer process receiving a interrupt every second then adding one to the timer counter.
1.12 Is the Internet a LAN or a WAN?
WAN
1.13 In a multiprogramming and time-sharing environment, several users share the system simultaneously. This situation can result in various security problems.
a. What are two such problems?
users could look into other users memory, and possibly read and change data
user could prevent another user from getting anything done
b. Can we ensure the same degree of security in a time-shared machine as in a dedicated machine? Explain your answer.
it is never possible to know if the program does not contain any bugs for resource allocation, however it is possible to know if the program can access or change other programs data
1.14 The issue of resource utilization shows up in different forms in different types of operating systems. List what resources must be managed carefully in the following settings:
a. Mainframe or minicomputer systems
Storage, network bandwidth, cpu
b. Workstations connected to servers
bandwidth, memory cpu
c. Handheld computers
memory, battery, cpu
1.15 Under what circumstances would a user be better off using a time-sharing system rather than a PC or a single-user workstation?
Time shairing bigger workloads as it maybe cheaper to buy one powerful machine instead of lots of machines, to maxamise utilisation, users require similar amounts of attention, and fewer users.
1.16 Identify which of the functionalities listed below need to be supported by the operating system for (a) handheld devices and (b) real-time systems.
a. Batch programming - b
b. Virtual memory - a
c. Time sharing - ab
1.17 Describe the differences between symmetric and asymmetric multiprocessing. What are three advantages and one disadvantage of multiprocessor systems?
Asymmetic - a master processor deals with the scheduling for each processor
Symmetric - all processors are incontrol of their own scheduling
dis: managing the threads to prevent race conditions
ad: can be quicker, allows for multiple programs to run at once, makes better utilisation of resources
1.18 How do clustered systems differ from multiprocessor systems? What is required for two machines belonging to a cluster to cooperate to provide a highly available service?
cluster - multiple separte machines all with their own memory and processors, commmunicate over a network via messages
multi - processors are all within the same system and shair memory, communicate via memory
1.19 Distinguish between the client-server and peer-to-peer models of distributed systems.
client-server - multiple clients mapped to a single server, single point of failure, server can be a master, everything goes through the server
peer-to-peer - peers are connected to each other, peers are all equal, if one goes down it wont kill the network
1.20 Consider a computing cluster consisting of two nodes running a database. Describe two ways in which the cluster software can manage access to the data on the disk. Discuss the benefits and disadvantages of each.
Symmetric clustering - both nodes are processing at the same time, the issue maybe race conditions
Asymmetric clustering - one does sits Idol for redundancy purposes incase another node goes down, however it will not utilise the full capability of both nodes
1.21 How are network computers different from traditional personal computers? Describe some usage scenarios in which it is advantageous to use network computers.
Network computers - have a central computer responsible for most of the services (cheaper for large workloads)
Personal computers - are responsible for all the services
1.22 What is the purpose of interrupts? What are the differences between a trap and an interrupt? Can traps be generated intentionally by a user program? If so, for what purpose?
Interrupt is when a process is stopped due to some kind of external reason, for example IO or the scheduler, leads to the process waiting or being sent to the ready queue
Trap is some kind of error that can be thrown by the OS or the process its self because of some kind of error, can lead to termination
1.24 Some computer systems do not provide a privileged mode of operation in hardware. Is it possible to construct a secure operating system for these computer systems? Give arguments both that it is and that it is not possible.
it is possible since the compiler or interpreter would provide the protection checks that the hardware is missing
1.25 Give two reasons why caches are useful. What problems do they solve? What problems do they cause? If a cache can be made as large as the device for which it is caching (for instance, a cache as large as a disk), why not make it that large and eliminate the device?
provide fast look up
are next to the cpu therefore dont need to check memory
regular items can be found faster, instead of checking an entire list
cache requires mantainence, to stay relivent
expensive
1.27 Discuss, with examples, how the problem of maintaining coherence of cached data manifests itself in the following processing environments:
a. Single-processor systems
b. Multiprocessor systems
c. Distributed systems
1.28 Describe a mechanism for enforcing memory protection in order to prevent a program from modifying the memory associated with other programs.
1.29 What network configuration would best suit the following environments?
a. A dormitory floor
b. A university campus
c. A state
d. A nation
1.30 Define the essential properties of the following types of operating systems:
a. Batch
b. Interactive
c. Time sharing
d. Real time
e. Network
f. Parallel
g. Distributed
h. Clustered
i. Handheld
1.31 What are the tradeoffs inherent in handheld computers?
1.32 Identify several advantages and several disadvantages of open-source operating systems. Include the types of people who would find each aspect to be an advantage or a disadvantage.
Chapter 2
2.1 What is the purpose of system calls?
For the user or programs to call certain serverces from the OS
2.2 What are the five major activities of an operating system with regard to process management?
- Create or Termination
- syncronsiation
- deadlock
- communication
- suspending and resuming them
2.3 What are the three major activities of an operating system with regard to memory management?
- Allocation and deallocation of processes
- Bring them in and out of virtual memory
- keeping track of which parts of memory are being used
2.4 What are the three major activities of an operating system with regard to secondary-storage management?
- disk scheduling
- storage allocation
- free space management
2.5 What is the purpose of the command interpreter? Why is it usually separate from the kernel?
Maps human commands into machine commands binary files and then executes them. It is separate from the kernel since it is easier for users to make new commands, since all they have to do is ad a bin file.
2.6 What system calls have to be executed by a command interpreter or shell in order to start a new process?
fork and exec
2.7 What is the purpose of system programs?
to provide packets of functionallity so that the user does not need to run each command each time they want to do something, they can just call the system program
2.8 What is the main advantage of the layered approach to system design? What are the disadvantages of using the layered approach?
- modularity, it is easier to debug as data is scoped, easier to understand
2.9 List five services provided by an operating system, and explain how each creates convenience for users. In which cases would it be impossible for user-level programs to provide these services? Explain your answer.
file management
security
error detection
communication
IO or device drivers
program execution
2.10 Why do some systems store the operating system in firmware, while others store it on disk?
there may not be a disk, for the firmware is large enough to store the OS, with the OS not being stored on disk there are advantages, since the computer is no-longer relient on the disk and the disk can be changed, it also takes up less space than on disk. the only issue with storeing the OS on firmware is that there can be no saved data/prefernces on it
2.11 How could a system be designed to allow a choice of operating systems from which to boot? What would the bootstrap program need to do?
on bootup a bootmanager is needed, this can select which OS you want to run, from here the os is loaded into memory
2.12 The services and functions provided by an operating system can be divided into two main categories. Briefly describe the two categories and discuss how they differ.
Services have kernel level access
Functions have user level access
2.13 Describe three general methods for passing parameters to the operating system.
- registers
- stack or queue
- address block
2.14 Describe how you could obtain a statistical profile of the amount of time spent by a program executing different sections of its code. Discuss the importance of obtaining such a statistical profile.
an interrupt could check periodically which process is currently running, and using a table could store such data. the advantage is knowing which parts of the process are taking up the most amount to cpu time, so that the programmer can optomise them
2.15 What are the five major activities of an operating system with regard to file management?
- creating and deleting files
- creating and deleting folders
- knowing what folders and files are mapped to secondary storage
- manipulating files
- moving files and folders
2.16 What are the advantages and disadvantages of using the same system-call interface for manipulating both files and devices?
quicker
user has more control
massive learning curve
2.17 Would it be possible for the user to develop a new command interpreter using the system-call interface provided by the operating system?
yes
2.18 What are the two models of interprocess communication? What are the strengths and weaknesses of the two approaches?
message passing model and the shaired memory model
2.19 Why is the separation of mechanism and policy desirable?
users may want to OS to run in different ways depending on the senario, this allows for the most amount of customisation
2.20 It is sometimes difficult to achieve a layered approach if two components of the operating system are dependent on each other. Identify a scenario in which it is unclear how to layer two system components that require tight coupling of their functionalities.
the different layers of memory are typically tightly linked
2.21 What is the main advantage of the microkernel approach to system design? How do user programs and system services interact in a microkernel architecture? What are the disadvantages of using the microkernel approach?
- new services does not require modifing the kernel
- more secure as more operations use user mode
- more reliable
typically harder to implement things using the system calls since there are less of them
2.22 In what ways is the modular kernel approach similar to the layered approach? In what ways does it differ from the layered approach?
communcation though interfaces is similar
except the layered approach lower level layers cannot invoke functions from higher level layers
2.23 What is the main advantage for an operating-system designer of using a virtual-machine architecture? What is the main advantage for a user?
easy to debug and solve security problems
user can run on multiple machines
2.24 Why is a just-in-time compiler useful for executing Java programs?
Allows for the same program to run as a native application on different devices
2.25 What is the relationship between a guest operating system and a host operating system in a system like VMware? What factors need to be considered in choosing the host operating system?
vmware will map its system calls to the system calls of the host os, a factor theymay need to be considered is does the host have enough system calls to provide all the functionallity to the guest
Chapter 3
3.1 Palm OS provides no means of concurrent processing. Discuss three major complications that concurrent processing adds to an operating system.
- time scheduling
- protection of processes
- prevention of deadlocks
3.2 The Sun UltraSPARC processor has multiple register sets. Describe what happens when a context switch occurs if the new context is already loaded into one of the register sets. What happens if the new context is in memory rather than in a register set and all the register sets are in use?
- registers and program counter are stored in the PCB
- the PCB is stored in memory
- an old PCB is loaded from memory into the processor
- program counter points to next instruction, the instruction is loaded, and execution beings
3.3 When a process creates a new process using the fork() operation, which of the following states is shared between the parent process and the child process?
a. Stack
b. Heap
c. Shared memory segments \
3.6 Describe the differences among short-term, medium-term, and long-term scheduling.
short-term - selects what is next to execute
medium-term - swaps processes in and out of CPU
long-term - adds processes to the ready queue
3.7 Describe the actions taken by a kernel to context-switch between processes.
- PCB stores the current state of a process, i.e. registers, state, program counter...
- PCB is then stored in memory
- Next context PCB is selected and loaded into the CPU
- Next instruction is loaded and process execution begins
3.8 Construct a process tree similar to Figure 3.9. To obtain process information for the UNIX or Linux system, use the command ps -ael. Use the command man ps to get more information about the ps command. On Windows systems, you will have to use the task manager.
COME BACK TO ME COS I AM UNLIKERLY
3.9 Including the initial parent process, how many processes are created by the program shown in Figure 3.28?
8
3.10 Using the program in Figure 3.29, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 2600 and 2603, respectively.)
A=0 B=2603 C=2603 D=2600
3.11 Give an example of a situation in which ordinary pipes are more suitable than named pipes and an example of a situation in which named pipes are more suitable than ordinary pipes.
Named pipes can be used over TCP
Unnamed pipes are used over interprocess comunication
Chapter 4
4.1 Provide two programming examples in which multithreading provides better performance than a single-threaded solution.
Web servers
Browser
4.2 What are two differences between user-level threads and kernel-level threads? Under what circumstances is one type better than the other?
kernel threads run in kernel mode, user threads run in user mode
kernel threads can run on a separate core
Since user threads need to be mapped to a kernel thread, it is hard to say that one is better than the other
4.3 Describe the actions taken by a kernel to context-switch between kernel-level threads.
Save register set stack and program counter, load another thread
4.4 What resources are used when a thread is created? How do they differ from those used when a process is created?
A thread is created within a process and require fewer resources, a process needs to have its own address space.
4.7 Provide two programming examples in which multithreading does not provide better performance than a single-threaded solution.
Programs that are squental and require step by step processing
program that says hello world
4.8 Describe the actions taken by a thread library to context-switch between user-level threads.
Save the state of the registers, and switch to another thread.
4.9 Under what circumstances does a multithreaded solution using multiple kernel threads provide better performance than a single-threaded solution on a single-processor system?
in cases where the same task is being performed different data, or when a different task that can be performed conrrently is being executed
4.10 Which of the following components of program state are shared across threads in a multithreaded process?
a. Register values no
b. Heap memory yes
c. Global variables yes
d. Stack memory no
4.11 Can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system than on a single-processor system? Explain.
yes and no,
yes in terms of responciveness, the program will appear quicker since it is running concurrently
no, the number of executions per unit time will if anything decrease since there will be time consumming context switches
4.13 The program shown in Figure 4.14 uses the Pthreads API. What would be the output from the program at LINE C and LINE P?
child = 0
parent = 5
4.14 Consider a multiprocessor system and a multithreaded program written using the many-to-many threading model. Let the number of user-level threads in the program be more than the number of processors in the system. Discuss the performance implications of the following scenarios.
a. The number of kernel threads allocated to the program is less than the number of processors.
it is possible for the program to run quicker since all cores are not being utilised
b. The number of kernel threads allocated to the program is equal to the number of processors.
maximum performace has been acheved
c. The number of kernel threads allocated to the program is greater than the number of processors but less than the number of user-level threads.
no better perfomace will be acheved having more kernel threads than there are cores
Chapter 5
5.1 A CPU-scheduling algorithm determines an order for the execution of its scheduled processes. Given n processes to be scheduled on one processor, how many different schedules are possible? Give a formula in terms of n.
n!
5.2 Explain the difference between preemptive and nonpreemptive scheduling.
preemptive - the midterm schedullar can pause execution of a process when an interrupt occures and it is put into the ready queue
non - the process must hand over and wait on its own terms
5.3 Suppose that the following processes arrive for execution at the times indicated. Each process will run for the amount of time listed. In answering the questions, use nonpreemptive scheduling, and base all decisions on the information you have at the time the decision must be made.

a. What is the average turnaround time for these processes with the FCFS scheduling algorithm?
10.5
b. What is the average turnaround time for these processes with the SJF scheduling algorithm?
9.5
c. The SJF algorithm is supposed to improve performance, but notice that we chose to run process P1 at time 0 because we did not know that two shorter processes would arrive soon. Compute what the average turnaround time will be if the CPU is left idle for the first 1 unit and then SJF scheduling is used. Remember that processes P1 and P2 are waiting during this idle time, so their waiting time may increase. This algorithm could be known as future-knowledge scheduling.
5.4 What advantage is there in having different time-quantum sizes at different levels of a multilevel queueing system?
low level queues may have processes with bigger cpu-bursts there for it makes sence to have a bigger time quantum to complete, as there are fewer context switches needed
5.6 Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors those processes that have used the least processor time in the recent past. Why will this algorithm favor I/O-bound programs and yet not permanently starve CPU-bound programs?
IO bound processes are quicker, the cpu will be availiable for cpu bound, when the io bound processes are waiting
5.7 Distinguish between PCS and SCS scheduling.
PCS OS scheduls based on the kernel thread
SCS OS schedules based on threads local to the process
5.9 Why is it important for the scheduler to distinguish I/O-bound programs from CPU-bound programs?
CPU bound programs will run on the cpu indefinantly, since there will be no point at which they will
5.10 Discuss how the following pairs of scheduling criteria conflict in certain settings.
a. CPU utilization and response time
b. Average turnaround time and maximum waiting time
c. I/O device utilization and CPU utilization
5.11 Consider the exponential average formula used to predict the length of the next CPU burst. What are the implications of assigning the following values to the parameters used by the algorithm?
a. α = 0 and τ0 = 100 milliseconds
b. α = 0.99 and τ0 = 10 milliseconds
5.12 Consider the following set of processes, with the length of the CPU burst given in milliseconds:

The processes are assumed to have arrived in the order P1, P2 , P3, P4, P5, all at time 0.
a. Draw four Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: FCFS, SJF, nonpreemptive priority (a smaller priority number implies a higher priority), and RR (quantum = 1).
b. What is the turnaround time of each process for each of the scheduling algorithms in part a?
c. What is the waiting time of each process for each of these scheduling algorithms?
d. Which of the algorithms results in the minimum average waiting time (over all processes)?
5.13 Which of the following scheduling algorithms could result in starvation?
a. First-come, first-served
b. Shortest job first
c. Round robin
d. Priority
5.14 Consider a variant of the RR scheduling algorithm in which the entries in the ready queue are pointers to the PCBs.
a. What would be the effect of putting two pointers to the same process in the ready queue?
b. What would be two major advantages and two disadvantages of this scheme?
c. How would you modify the basic RR algorithm to achieve the same effect without the duplicate pointers?
5.15 Consider a system running ten I/O-bound tasks and one CPU-bound task. Assume that the I/O-bound tasks issue an I/O operation once for every millisecond of CPU computing and that each I/O operation takes 10 milliseconds to complete. Also assume that the context-switching overhead is 0.1 millisecond and that all processes are long-running tasks. Describe the CPU utilization for a round-robin scheduler when:
a. The time quantum is 1 millisecond
b. The time quantum is 10 milliseconds
5.16 Consider a system implementing multilevel queue scheduling. What strategy can a computer user employ to maximize the amount of CPU time allocated to the user’s process?
5.17 Consider a preemptive priority scheduling algorithm based on dynamically changing priorities. Larger priority numbers imply higher priority. When a process is waiting for the CPU (in the ready queue, but not running), its priority changes at a rate α; when it is running, its priority changes at a rate β. All processes are given a priority of 0 when they enter the ready queue. The parameters α and β can be set to give many different scheduling algorithms.
a. What is the algorithm that results from β > α > 0?
b. What is the algorithm that results from α < β < 0?
5.18 Explain the differences in how much the following scheduling algorithms discriminate in favor of short processes:
a. FCFS
b. RR
c. Multilevel feedback queues
5.19 Using the Windows XP scheduling algorithm, determine the numeric priority of each of the following threads.
a. A thread in the REALTIME_PRIORITY_CLASS with a relative priority of HIGHEST
b. A thread in the NORMAL_PRIORITY_CLASS with a relative priority of NORMAL
c. A thread in the HIGH_PRIORITY_CLASS with a relative priority of ABOVE_NORMAL
5.20 Consider the scheduling algorithm in the Solaris operating system for time-sharing threads.
a. What is the time quantum (in milliseconds) for a thread with priority 10? With priority 55?
b. Assume that a thread with priority 35 has used its entire time quantum without blocking. What new priority will the scheduler assign this thread?
c. Assume that a thread with priority 35 blocks for I/O before its time quantum has expired. What new priority will the scheduler assign this thread?
5.21 The traditional UNIX scheduler enforces an inverse relationship between priority numbers and priorities: the higher the number, the lower the priority. The scheduler recalculates process priorities once per second using the following function:
Priority = (recent CPU usage / 2) + base
where base = 60 and
recent CPU usage
refers to a value indicating how often a process has used the CPU since priorities were last recalculated.
Assume that recent CPU usage for process P1 is 40, for process P2 is 18, and for process P3 is 10. What will be the new priorities for these three processes when priorities are recalculated? Based on this information, does the traditional UNIX scheduler raise or lower the relative priority of a CPU-bound process?
Chapter 3
6.3 Explain why Solaris, Windows XP, and Linux implement multiple locking mechanisms. Describe the circumstances under which they use spinlocks, mutexes, semaphores, adaptive mutexes, and condition variables. In each case, explain why the mechanism is needed.
- Busy loop or spinlock - needed in situations where the process me not be waiting for very long, i.e. semaphore
- mutex - needed for situations where only one thread can change a value at a time, a mutex that is implemented using spinlock, this is okay if the thread is not going to be waiting for long
- Adaptive mutex - sleeps if the tread it is waiting on is inactive, or will spin if it is
- semaphore - needed when there is a limited number of threads that can perform an action at a time, do not use spin locks
6.4 Describe how volatile, nonvolatile, and stable storage differ in cost.
Volatile is typically more expencive, non volitile is more expencive if it is solid state otherwise it is cheaper
6.5 Explain the purpose of the checkpoint mechanism. How often should checkpoints be performed? Describe how the frequency of checkpoints affects:
• System performance when no failure occurs
• The time it takes to recover from a system crash
• The time it takes to recover from a disk crash
A checkpoint is when a certain point is reached where the data is stable, and then can be written to secondary storage, if a system failure occurs, then the OS can resume from the last checkpoint
6.6 Explain the concept of transaction atomicity.
Where a transaction can be performed with one cpu cycle