Search the whole station

操作系统期末代考 CSC369 HlF代写 操作系统代写 操作系统代考

CSC369 HlF

操作系统期末代考 Duration: 3 hours Do not turn this page until you have received the signal to start. In the meantime, please read carefully every reminder

Duration: 3 hours

Do not turn this page until you have received the signal to start. In the meantime, please read carefully every reminder on this page.

Question 1. Circle the correct answer. [10 MARKS]

TRUE FALSE A context switch from one process to another can be accomplished without executing OS code in kernel mode.

TRUE FALSE In round robin scheduling, it is advantageous to give each I/O bound process a longer quantum than each CPU-bound process (since this has the effect of giving the I/O bound process a higher priority).

TRUE FALSE Code that uses semaphores for synchronization can correctly be rewritten using semaphores and code that uses condition variables for synchronization can correctly be rewritten to use semaphores.

TRUE FALSE A TLB miss always results in a page being swapped in from disk.

TRUE FALSE A major fault results in a page being swapped in from disk.

TRUE FALSE Paged memory suffers from internal fragmentation.

TRUE FALSE A page that has just been brought into physical memory from the swap should have its dirty bit set.

TRUE FALSE In the ext2 file system, we could use a binary search to find a directory entry within a directory if the entries were sorted.

TRUE FALSE A hard link is just an entry in a directory

TRUE FALSE If a system is using a Journaling File System, that means that when a program returns from a write statement, we are guaranteed that the file is updated on disk.

Question 2. [10 MARKS] 操作系统期末代考

1.Which of the following components are shared between threads in a multithreaded process? (Check all that apply)

  • heap memory
  • stack memory
  • code
  • program counter

2.The program xxd outputs the byte sequencei eca1 0455. This sequence represents an integer in little-endian byte order. Which of the following shows the integer in “normaln order (big-endian)? (Check one)

  • eca1 0455
  • 5504 a1ec
  • a1ec 5504
  • 1ace 5540
  • 5540 1ace

3. 操作系统期末代考

xxd outputs the following sequence of bytes: 6566 5768. What string does it represent? (Check one) (Relevant ASCII values: i8i = 56i igi = 57i iAi = 65i iBi = 66i ini = 68i iKi = 75i iv = 76i iyi = 86)

  • AB9D
  • D9BA
  • 9DAB
  • 8BKV
  • VKB8

4.The copy-on-write mechanism provides: (Check all that apply)

  • an efficient way to create new processes
  • a way to delay writes to disk
  • a clever way to share virtual memory pages (at least temporarily)
  • a way to avoid unnecessary page copying
  • a way to map file data into memory

5.Implementing LRU precisely in an OS is expensivei so practical implementations use an algorithm that approximates LRU called: (Check one)

  • MRU
  • LFU
  • OPT
  • FIFO
  • none of the above

6. 操作系统期末代考

For two processes accessing a shared variable, Peterson’s algorithm provides (Check all that apply):

  • mutual exclusion
  • bounded waiting
  • no preemption
  • progress
  • preventing circular waiting

7.In assignment 4, ext2 _rm was implemented to minimize changes to the inode and deleted directory entry. This allowed you to write a program to recover deleted files or directories. Check all the boxes below that are true statements.

  • An entry in a gap between two existing entries can not be
  • If a gap between two existing entries had more than one deleted entry, only the first can be
  • The first entry in a directory block can not be
  • An entry directly after the last existing entry in a block can not be
  • A file whose data blocks are currently marked as in-use cannot be

8.Which of the following are stored in an ext2 inode? (Check all that apply)

  • file size
  • file name
  • array of pointers to blocks
  • type of the file
  • location of block bitmap
  • number of links

9. 操作系统期末代考

When adding a new block to a file, which of the following data structures need to be written to disk to complete the operation. (Check all that apply)

  • inode bitmap
  • directory data block
  • inode
  • data block
  • block bitmap

10.When adding a new block to a file, which of the following data structures should be written to disk last to minimize file system inconsistency in the event of a crash? (Check one)

  • inode bitmap
  • directory data block
  • inode
  • data block
  • block bitmap

Question 3. Short Answer [11 MARKS] 操作系统期末代考

Part (a) [2 MARKS]

Why must the operating system be more careful when accessing input to a system call when the data is in memory instead of registers?

Part (b) [l MARK]

What crucial piece of information does the banker’s algorithm need to be able to avoid deadlock?

Part (c) [1 MARK]

In the traffic intersection problem in A2, what strategy was used to prevent deadlock? Be specific.

Part (d) [3 MARKS]

CLOCK is an approximation of LRU. Describe a scenario where the accuracy of CLOCK would suffer.

Part (e) [4 MARKS]

One of the themes of the course was virtualization. Identify three contexts in which virtualization was used as a solution technique. Briefly discuss the technical issues involved, and the benefits of the virtualization approach to the problem.

Question 4. Process states [5 MARKS]

Part (a) [1 MARK]

What are the three main states that a process can be in?

Part {b) [4 MARKS]

December 2018 Assume you have a single CPU and three processes (X, Y, and Z). Process X has the highest priority, process Z has the lowest, and Y is in the middle. Assume a priority-based pre-emptive scheduler. Given the following cumulative timeline of process behavior, indicate the state the specified process is in after that step, and all preceding steps, have taken place. Assume the scheduler has reacted to the specified workload change.

操作系统期末代考
操作系统期末代考

Question 5. Scheduling [8 MARKS] 操作系统期末代考

Consider a multi-level feedback queue scheduler where the first two rules are specified below. (A and Bare processes.)

  • Rule 1: If Priority(A) > Priority(B), A runs (B does not).
  • Rule 2: If Priority(A) = Priority(B), A and Brun in round-robin fashion using the time slice(quantum length) of the given queue.

Part (a) [6 MARKS]

For each of the questions below, define a new rule that will address the question.

i- [2 MARKS] In which queue should a job start when it enters the system?

ii- [2 MARKS] What event causes a job to move to a lower-priority queue?

iii- [2 MARKS] How does the algorithm prevent starvation?

Part (b) [2 MARKS]

What type of processes are given priority? Explain why.

Question 6. Synchronization [10 MARKS] 操作系统期末代考

Imagine a help centre with 4 seats. If you arrive while there is an empty seat, you can take a seat immediately. But if you arrive when all 4 seats are full, that means that all of students there are getting help for the same problem, and you will have to wait for all 4 to leave before you sit down.

Part (a) [3 MARKS]

Explain clearly why the code on the next page does not solve the problem. Use a concrete example to aid your explanation.

Part (b) [7 MARKS J

Without using any more semaphores or adding any more variables, rewrite the code below to provide a correct solution to the help centre. You may assume that the variables and semaphores are declared and initialized as in the provided code.

// INCORRECT SOLUTION
//Global variables
static struct semaphore *mutex;
static struct semaphore *waiting_to_sit;
int num_working = O;
int num_waiting - O;

sem_create(mutex, 1);
sem_create(waiting_to_sit, O)

// Code executed by each person
//(recall that P ==wait, and V ==signal)
P(mutex);
if (num_working == 4 ) {
    num_waiting += 1;
    V(mutex);
    P(waiting_to_sit);

    P(mutex); //reacquire mutex
    num_waiting -= 1;
}
num_working += 1;
V(mutex);

// get help from instructor

P(mutex);
num_working -= 1

if (num_working == 0 k& num_waiting > 0) {
    // set n to the minimum of 4 and num_waiting
    int n = min(4, num_waiting);
    for(int i = O; i < n; i++) {
        V(waiting_to_sit);
    }
}
V(mutex);

Question 7. Address Translation [12 MARKS] 操作系统期末代考

In this question, we will perform address translation using the physical memory dump on page 17. (You may tear off the page to avoid flipping back and forth.) Note that the physical memory dump may be bigger or smaller than the actual physical memory in one or both of the questions.

Remember: Each hexadecimal digit is 4 bits in binary.

Part (a) Linear page table [6 MARKS]

Considering the linear page table configuration below.

  • PTBR: 13 (PTBR = Page Table Base Register)
  • Virtual address format: 5-bit virtual page number, 4-bit offsets

8 7 6 5 4 3 2 1 0

VPNOffset
  • PTE size: 1 byte
  • PTE format: Valid bit, on Swap bit, Dirty bit, Ref bit followed by 4-bit PFN

7 6 5 4 3 2 1 0

vsDRPFN

i- [2 MARKS] Fill in the values in the table below assuming all the bits are used in the virtual address and page frame numbers. Use decimal (base 10) in your answers. Sizes should be expressed in bytes.

Page size (virtual and physical) 
Virtual address space size 
Physical memory size 
Number of pages needed for page table 

ii- [4 MARKS] Find the data stored at virtual address Ox05a by filling in the following table. Fill irrelevant fields with “N /A”, for example if it is a page fault.

Virtual Address (in hex)Ox050a
Content of PTE (in hex) 
PFN of data (in decimal) 
Offset (in decimal) 
Content of data byte ( 1 byte in hex) 

Part (b) Two-level Page Table [ 6 MARKS] 操作系统期末代考

Consider the two-level page table configuration below:

  • PDBR: 23
  • Virtual address format: 3-bit Page directory index, 3-bit page table index, 4-bit offset

9 8 7 6 5 4 3 2 1 0 

PD IndexPT IndexOffset
  • PTE size: 1 byte
  • PDE/PTE format: Valid bit, on Swap bit, Dirty bit followed by 5-bit PFN

7 6 5 4 3 2 1 0

vsDPFN

Find the data stored at virtual address Ox14f by filling in the following table. Fill irrelevant fields with “N /A”, for example i£ it is a page fault.

Virtual Address (in hex)Ox14f
Content of PDE (in hex) 
PFN of 2nd level table (in decimal) 
Content of PTE (in hex) 
PFN of data (in decimal) 
Offset (in decimal) 
Content 0£ data byte (1 byte in hex) 

Question 8. File Systems [15 MARKS] 操作系统期末代考

A defragmentation program reorganizes the blocks on a disk to maximize the contiguous free space on the disk. You can think of the blocks on the disk as an array, where the block number is an index into the array.

Consider the following two algorithms:

  • Alg. A: Free blocks are filled by used blocks from the end of the disk.
  • Alg. B: Blocks are moved around until all the files in the block group are stored contiguously.

Part (a) [1 MARK]

Which of the two algorithms would complete faster on average? Explain your thinking.

Part (b) [2 MARKS)

Which of the two algorithms would lead to better performance in terms of time to access blocks during normal operation? Assume we are using a magnetic disk. Explain clearly.

Part (c) [2 MARKS]

Consider an inode based-file system like ext2. What changes, if any, are made to the inodes? Explain your answer.

Part (d) [2 MARKS)

Consider an inode based-file system like ext2. What changes, if any, would need to be made to the directory metadata by the defragmentation algorithm? Explain your answer.

Part ( e) [2 MARKS]

Consider a linked file system structure like FAT. What changes, if any, are made to the FAT (File Allocation Table) by the defragmentation algorithm? Explain your answer.

Part (f) (2 MARKS]

Consider a linked file system structure like FAT. What changes, if any, are made to the directory metadata by the defragmentation algorithm? Explain your answer.

Part (g) [4 MARKS]

Solid-state hard drives have uniform access time to all parts of the drive.

i- [2 MARKS] Explain one reason why you might not want to move blocks around so that they are close to other blocks from the same file.

ii- [2 MARKS] Explain one reason why you might still want blocks from the same file to be close together on the drive.

操作系统期末代考
操作系统期末代考

更多代写:单精度代写  ielts indicator代考  英国高中代写  分析类论文代写  翻译research proposal范文  英文读后感怎么写

合作平台:essay代写 论文代写 写手招聘 英国留学生代写

The prev: The next:

Related recommendations

1
您有新消息,点击联系!