[OSC] Problem sheet 3

1.A computer system is mainly used for non-interactive work where jobs (processes) arrive randomly, persist until completed and then leave the system. There may be many processes that need scheduling concurrently. Describe two process scheduling algorithms that would be suitable for this system and explain why they are appropriate. A different system deals mainly with multiple, concurrent, interactive processes. Give two process scheduling algorithms for this situation and explain why they are appropriate. A new system is to be developed that will run a mix of the two types of processes. Are any of the previous scheduling algorithms appropriate? Describe one new algorithm that could be used.
First, we should know what the question is really asked about?
  • non-interactive work is like you open one process, the result is done. If you scroll the page by mouse, it is a interactive work because you make an I/O and the computer response.
  • Also a non-interactive work is like CPU bounded. So what algorithms should be used for CPU bounded?
  • Round Robin(remember round robin favors CPU bounded more than I/O bounded)
  • And FCFS, because there will be I/O, the operation will be fast and no need to preemptive
Also, for interactive work which is like I/O bounded:
  • Shorest job first and priority queue.
  • Remember priority queue can prioritise I/O bounded jobs
For the mixture, it should be multi-level feedback queue, which Linux and Windows do.
2.What are the two advantages that threads have over multiple processes?
  • Threads incur less overhead to create/terminate/switch (address space remains the same for threads of the same process)
  • When there is a blocking system call or interrupt, process are blocked but if we divide them to several threads, only one related thread will be blocked but others keep running.
  • (The same to point one)Inter-thread communication is easier/faster than interprocess communication (threads share memory by default)
3.Describe how you would implement the least recently used (LRU) page replacement algorithm in hardware. Is this algorithm the best in all cases? Why?
  • Hardware! On the ppt, it says:
  • enter image description here
4.It has been suggested that the first part of each UNIX file be kept in the same disk block as its i-node. What, if any, would be the advantage of doing this?
  • Often, files are short. If the entire file fit in the same block as the inode, only one disk access would be needed to read the file, instead of two, as is presently the case. Even for longer files there would be a gain, since one fewer disk access would be needed.
5.What is kernel mode, why is it needed and why are interrupts often implemented via an interrupt vector? How do these influence the events that need to take place to make a context switch?
Kernel mode is the privileged mode to be able to access all the instruction set.
  • Interrupt cause context switch
  • In the context switch, the access PCB will be in kernel mode.
6.enter image description here
What is associative memory?
It is TLB!
Thus, everything is happy
7.A multi-threaded CPU bound process is running on a machine with a multi-core CPU. Ignoring the overhead of context switching and thread creation, would you expect the process to finish quicker when user level threads are used, or when kernel level threads are used. Briefly explain your answer.
  • user level threads.
  • Because ignoring overhead of context switching we still have syscall

评论

此博客中的热门博文

[MLE] Linear Classification

[AIM] MetaHeuristics

[CS231] Neural Networks