Past Quizzes

Cards (39)

  • explain what a process is in OS
    a running program
  • is it true that each process has an illusion of having complete CPU
    Yes
  • Is it true that a CPU usually implements a certain kind of ISA
    yes
  • Order the following by their read/write speed, from the fastest to the slowest: Register, Cache, Memory, HDD
    Registers are the fastest because they are located directly in the CPU (1). Next is a cache because they store frequently accessed data and instructions (~10). Next is memory because it has faster read and write speeds compared to HDD (~100). HDD is last because it has slow access times and data transfer rates (~1000).
  • what kind of memory addresses does a process use
    virtual memory address
  • how many processes can you launch at the same time if your computer only has 2 physical cores
    unlimited
  • from the view of a process, does the process think it has a dedicated memory space for itself
    Yes
  • given a 32-bit system where each page size is 4KB, the size of each page table entry is 8 bytes. Calculate the number of page table entries required for each process. Then calculate the size of each page table, assuming only 50% of each page is filled with data by the process
    2^32/2^12 = 2^20 entries
    2^20 x 8 bytes
  • explain external and internal fragmentation
    external fragmentation occurs when a process is removed, causing little bits of spaces between non-contiguous memory with no use.
    internal fragmentation occurs when a process uses less space than given, causing space that is unused.
  • In base and bound register memory management scheme, say if the base is 64KB, the bound is 32KB, what is the physical address of the virtual address 64KB
    Fault
  • Consider the following line of code: int *x = (int *)malloc(10 * sizeof(int)); which segment is the variable x allocated within the memory image of the process
    stack
  • Where is the memory for the 20 integer variables allocated within the memory image of the process
    heap
  • when a TLB hit happens, MMU will still need to access memory to get the target physical address in page table
    false
  • page table is per process
    true
  • frequent context switches between multiple processes will reduce TLB hit rate
    true
  • TLB entries can be re-used by different processes
    false
  • in different processes, the physical addresses of the kernel code stored in the page tables of the processes are different
    false
  • if we increase the size of page in a system, the size of the page table of a process will be increased
    false
  • if we increase the size of a page in a system, we will observe more internal fragmentation of main memory
    true
  • the RAM can hold 3 physical frames while a process contains 4 virtual pages. The process generates a sequence of references that are the following virtual pages: 3,2,0,2,1,3,1,0; How many page faults are there if using LRU policy.
    6 page faults. first 3 are cold misses
  • in a perfect LRU algorithm in page replacement policy, one implementation is to keep a doubly linked list of pages where the front of the list is the most recently used page, and the end is the least recently used page. On a page access, move the page to the front of the list. if there are 100 virtual pages in the system, and 20 physical page frames in the main memory, how many pointer updates would be necessary to uphold the algorithm's functionality in a worst-case page access scenario
    5. 100/20 = 5
  • locks can be implemented by software and do not need any support from hardware.
    false
  • creating user-level threads in Linux will not always ensure to create corresponding kernel-level threads.
    true
  • one does not need to use locks in a single processor system in order to safely access kernel data structures. instead, just disable interrupts
    true
  • each thread in a process has its own PC
    true
  • a new copy of memory image of process need to be created if a new thread it created by the process
    false
  • parent process and child process usually share one copy of memory image
    false
  • different threads of a process own different stacks
    true
  • say a process created 20 user-level threads. the library maps these 20 threads on to 6 kernel threads. the process is executing on an 8-core system. what's the maximum number of threads of a process can run in parallel
    6
  • small pages
    multiprogramming, reduce internal fragmentation
  • large pages
    smaller page table, less page faults
  • future trend of page size
    increase, physical memory is cheap, CPU speed is increasing faster than disk speed
  • There are 3 processes (A, B and C). A has a duration of 2s, B has a duration of 6s, and C has a duration of 2s. They arrive at the same time when T=0s. What is the average turnaround time in the shortest-job-first and shortest-remaining-time-first scheduling algorithmsrespectively?
    5.33s
  • Which of the following pieces of information in the PCB of a process are changed when the process invokes the exec system call? (a) Process identifier (PID) (b) Page table entries (c) The value of the program counter stored within the user space context on the kernel stack
    Answer: (b) and (c) change because the process gets a new memory image
  • Consider a system with N bytes of physical RAM, and M bytes of virtual address space per process. Pages and frames are K bytes in size. Every page table entry is P bytes in size, accounting for the extra flags required and such. Calculate the size of the page table of a process.
    M/K * P
  • When a C++ executable is run on a Linux machine, the kernel code is part of the executable generated during the compilation process.
    False
  • The page size in a system (running a Linux-like operating system on x86 hardware) is increased while keeping everything else (including the total size of main memory) the same. For each of the following metrics below, indicate whether the metric is generally expected to increase, decrease, or not change as a result of this increase in page size
    (a) PT size decreases (b) TLB hit rate increases(c) Internal fragmentation increases
  • Answer yes/no, and provide a brief explanation. (a) Is it necessary for threads in a process to have separate stacks? (b) Is it necessary for threads in a process to have separate copies of the program executable?
    (a) Yes, so that they can have separate execution state, and run independently. (b) No, threads share the program executable and data
  • Can one have concurrent execution of threads/processes without having parallelism? If yes, describe how. If not, explain why not.
    Yes, by time-sharing the CPU between threads on a single core.