CS703 – Operating Systems: Midterm Important Subjective (45 Solved Q&As)

Virtual University of Pakistan • Read every solved subjective question with its model answer directly on this page. Free, no login required.

All 664 Midterm Packs · CS703 Course Page · CS703 MCQ Pack (73 MCQs)

  1. What are the five major activities of an operating system in regard to process management?
    Topic: Operating System Fundamentals

    The five major process management activities of an operating system are: (a) Creation and deletion of user and system processes. (b) Suspension and resumption of processes. (c) Provision of mechanisms for process synchronization. (d) Provision of mechanisms for process communication. (e) Provision of mechanisms for deadlock handling.

  2. What are the three major activities of an operating system in regard to memory management?
    Topic: Operating System Fundamentals

    The three major memory management activities of an operating system are: (a) Keeping track of which parts of memory are currently being used, and by whom. (b) Deciding which processes are to be loaded into memory when memory space becomes available. (c) Allocating and freeing memory space as needed.

  3. What are the three major activities of an operating system in regard to secondary-storage management?
    Topic: Operating System Fundamentals

    The three major secondary-storage management activities of an operating system are: free-space management, storage allocation, and disk scheduling.

  4. What are the five major activities of an operating system in regard to file management?
    Topic: Operating System Fundamentals

    The five major file management activities of an operating system are: (a) Creation and deletion of files. (b) Creation and deletion of directories. (c) Support of primitives for manipulating files and directories. (d) Mapping of files and directories onto secondary storage. (e) Backup of files on stable (nonvolatile) storage media.

  5. What is the purpose of the command interpreter? Why is it usually separate from the kernel?
    Topic: Operating System Fundamentals

    The command interpreter is the interface between the user and the operating system. Its function is simple: to get the next command statement and execute it. It is usually separate from the kernel because it is not needed for the working of the kernel itself; keeping it outside the kernel keeps the kernel smaller and makes it easy to change or replace the interpreter (for example, to give different users different shells) without modifying the kernel.

  6. What is the purpose of system calls? What are the main types of system calls?
    Topic: Operating System Fundamentals

    System calls provide the interface between a process and the operating system. These calls are usually available both from assembly-language programs and from higher-level language programs. The main types are: Process control: end, abort; load, execute; create process, terminate process; get/set process attributes; wait for time; wait event, signal event; allocate and free memory. File management: create file, delete file; open, close; read, write, reposition; get/set file attributes. Device management: request device, release device; read, write, reposition; get/set device attributes; logically attach or detach devices. Information maintenance: get/set time or date; get/set system data; get/set process, file or device attributes. Communications: create, delete communication connection; send, receive messages; transfer status information; attach or detach remote devices.

  7. What are the two main functions of an operating system?
    Topic: Operating System Fundamentals

    An operating system must provide the user with an extended (i.e. virtual) machine, and it must manage the I/O devices and other system resources.

  8. What is multiprogramming? What is the difference between multiprogramming and timesharing systems? What is spooling?
    Topic: Operating System Fundamentals

    Multiprogramming is the rapid switching of the CPU between multiple processes in memory. It is commonly used to keep the CPU busy while one or more processes are doing I/O. Timesharing is a logical extension of multiprogramming in which the CPU is switched between processes so frequently (using timer interrupts and preemptive scheduling) that many users can interact with their programs at the same time; multiprogramming by itself only aims at keeping the CPU busy and does not require interactive response. Spooling (Simultaneous Peripheral Operations On-Line): input spooling is the technique of reading in jobs, for example from cards, onto the disk, so that when the currently executing processes are finished, there will be work waiting for the CPU. Output spooling consists of first copying printable files to disk before printing them, rather than printing directly as the output is generated.

  9. What is the key difference between a trap and an interrupt?
    Topic: Operating System Fundamentals

    A trap is caused by the program itself and is synchronous with the program's execution (for example, a system call or a division by zero), whereas an interrupt is caused by an event external to the processor, such as an I/O device completing an operation, and is asynchronous.

  10. What is the difference between kernel mode and user mode? How does having two distinct modes aid in the design of an operating system?
    Topic: Operating System Fundamentals

    In kernel mode the CPU can execute every instruction and access all of memory and hardware; in user mode only a safe subset of instructions is allowed and direct access to hardware and protected memory is forbidden. Having two modes protects the operating system from erroneous or malicious user programs: a user program that crashes or tries to access protected resources is stopped by the hardware, sensitive operations can only be performed by the kernel through controlled system calls, and this clear boundary makes the system more reliable and secure.

  11. Explain how the separation of policy and mechanism aids in building microkernel-based operating systems.
    Topic: Operating System Fundamentals

    The microkernel implements only the basic mechanisms (such as message transport, loading programs into memory and device handling) in the kernel, while policy decisions are made by user-level servers in user space. Because mechanisms do not dictate policy, policies can be changed, replaced or extended by modifying user-level services without touching the kernel, which makes the system flexible, modular and easier to maintain.

  12. What are the advantages and disadvantages of the microkernel architecture?
    Topic: Operating System Fundamentals

    Advantages: (a) adding a new service does not require modifying the kernel; (b) it is more secure, as more operations are done in user mode than in kernel mode; and (c) a simpler kernel design and functionality typically results in a more reliable operating system. The primary disadvantage of the microkernel architecture is the overhead associated with inter-process communication and the frequent use of the operating system's messaging functions in order to enable the user process and the system service to interact with each other.

  13. For each of the following system calls, give a condition that causes it to fail: fork, exec and unlink.
    Topic: Operating System Fundamentals

    fork fails when the system has reached its limit on the number of processes (or there is not enough memory) to create a new process. exec fails when the named file does not exist, is not executable, or is not in a recognizable executable format. unlink fails when the file does not exist or the user does not have permission to remove it (for example, the directory is not writable by the user).

  14. In the fork_test() function given below, how many processes would be created in total, excluding the main process that called fork_test()? How many times will "Whatsup" be printed? Explain briefly. void fork_test() { if (fork() != 0) { if (fork() != 0) fork(); else printf("Hello 1"); } else { if (fork() != 0) { printf("Hello"); } else { fork(); } } printf("Whatsup"); }
    Topic: Processes and Threads

    Five processes are created, excluding the main process that called fork_test(). The "Whatsup" line is printed six times, because each process (the original plus the five created) reaches and executes this line. The condition (fork() != 0) is false in a child process, because fork() returns 0 in the child; it is true for the parent, because the parent receives the child's non-zero PID (and -1 would indicate an error). Tracing the code: the parent passes the first test, passes the second test and forks again; that new child fails the second test and prints "Hello 1". The child of the first fork fails the first test, enters the else part; there the parent of that branch passes the inner test and prints "Hello", while its child fails the test and forks once more. In this way five new processes are created, and since all six processes execute the final printf, "Whatsup" is printed six times.

  15. How is a thread created? Sometimes a thread may not be created — why?
    Topic: Processes and Threads

    A thread is created by the operating system (or thread library) when a process requests it, for example through a call such as pthread_create() in POSIX. The system allocates a thread control block, a separate stack and a register set for the new thread, records it in the process's thread table, and places it on the ready queue so the scheduler can run it; the thread shares the code, data, heap and open files of its parent process. Sometimes the thread cannot be created: the system may have reached the maximum number of threads allowed per process or for the whole system, or there may not be enough memory/resources (for example, stack space) available, in which case the creation call fails and returns an error.

  16. Why is it considered that threads are harmful?
    Topic: Processes and Threads

    Threads are a difficult thing to handle for most programmers. Bugs can be introduced easily by the programmers while using threads, and the most annoying thing is that these are hard to find and even harder to fix. The things are painful for experts, so inexperienced programmers consider threads harmful. During synchronization, it is required that threads must coordinate access to shared data with proper locks, and missing a lock results in corruption of data. Threads also cause deadlocks if used inefficiently or carelessly. The main purpose of using threads is concurrency, but this is hard. Hence threads are considered harmful and are avoided by normal programmers.

  17. Give some reasons to use threads in a beneficial way.
    Topic: Processes and Threads

    Threads can be used for concurrency, and the responsiveness of applications is increased when threads are used with care. Performance and utilization of multi-core, multi-CPU systems is increased with multiple threads running on multiple CPUs, each thread running in parallel on a different processor. The efficiency of high-end servers is increased. Threads share the memory and resources of the process to which they belong, and code sharing allows an application to have several different threads of activity all within the same address space.

  18. Which are the classical issues related to threads?
    Topic: Processes and Threads

    Synchronization and deadlocks are the main issues related to threads, and the classical problems are: 1. Bounded Buffer Problem 2. Readers and Writers Problem 3. Dining Philosophers Problem

  19. A multithreaded solution using multiple kernel threads gives better performance than a single-threaded solution on a single-processor system. Under what conditions does this occur?
    Topic: Processes and Threads

    When a kernel thread suffers a page fault, another kernel thread can be switched in to use the interleaving time in a useful manner. A single-threaded process, on the other hand, will not be capable of performing useful work when a page fault takes place. Therefore, in scenarios where a program might suffer from frequent page faults or has to wait for other system events, a multithreaded solution would perform better even on a single-processor system.

  20. In lectures, three methods to achieve concurrency were studied. What is the difference between the second method (single process, multiple events) and the third method (threads)?
    Topic: Processes and Threads

    In the second method, a single process handles many activities using an event-driven style: it issues non-blocking operations and uses an event loop to react to completions, maintaining the state of each activity explicitly in its own data structures. There is only one thread of control and one stack, so there are no race conditions, but the programmer must save and restore state manually and structure the program as state machines. In the third method (threads), several threads run inside one process, each with its own stack and program counter, sharing the same address space; the kernel schedules them preemptively, so blocking calls are natural to write, but shared data must be protected with locks and synchronization, which introduces races and deadlocks.

  21. Describe what problems would happen when multiple threads execute the following C statement, and justify your answer. { static int I; I++; }
    Topic: Processes and Threads

    1. Incorrect ordering / lost update: the statement I++ is not atomic — it is a load, an increment and a store. When two threads increment the counter concurrently, both may load the same old value, so the result can be 1 instead of 2. 2. Concurrency issues: static fields exist only once, so if code reads and writes static (shared) fields, threads can read stale data and produce wrong outputs when they update the shared resource concurrently. 3. Race condition: the outcome depends on which thread reaches the code first and on the thread scheduling order, so repeated runs can give different, unpredictable results. 4. Deadlock can also arise in such code once locks are added carelessly to protect the shared variable: two threads may each lock a resource the other needs and wait forever. Hence shared data like the static variable I must be protected (for example with a mutex) so that the increment executes atomically.

  22. Review the Readers/Writers problem discussed in Lecture 12. Write the code for the Reader() and Writer() functions when readers are given priority over writers, keeping the problem constraints in mind.
    Topic: Synchronization

    Shared data: semaphore mutex = 1 (protects readcount); semaphore wrt = 1 (writer access / first reader locks, last reader unlocks); int readcount = 0. Writer(): wait(wrt); ... writing is performed ... signal(wrt); Reader(): wait(mutex); readcount++; if (readcount == 1) wait(wrt); signal(mutex); ... reading is performed ... wait(mutex); readcount--; if (readcount == 0) signal(wrt); signal(mutex); Because a steady stream of readers can keep readcount above zero, writers may starve in this readers-priority version.

  23. Reader/writer locks are used to solve the readers/writers problem. In the semaphore implementation, why do AcquireReadLock() and AcquireWriteLock() perform P and V operations on the mutex semaphore? Could readers or writers be starved in this implementation? Suggest how a starvation-free implementation can be achieved.
    Topic: Synchronization

    The mutex semaphore protects the shared bookkeeping variables of the lock (such as the reader count and the lock state). AcquireReadLock and AcquireWriteLock must read and update this state atomically; without the P/V pair on mutex, two threads could interleave their updates and corrupt the count, admitting a writer while readers are active or losing track of waiting threads. Starvation is possible: in the usual readers-preference version, a continuous stream of readers keeps the lock in read mode and a writer can wait indefinitely (writer starvation); symmetric writer-preference versions can starve readers. A starvation-free policy can be implemented by serving requests in arrival order: add a fair (FIFO) queueing/turnstile semaphore that every reader and writer must pass through in order, so that once a writer is waiting, later readers cannot overtake it, and readers already inside finish and let the writer proceed; this bounds the waiting time of both readers and writers.

  24. How should threads coordinate? How should they wait for an event or a state change?
    Topic: Synchronization

    A thread, while holding the lock, may change the variables constituting the condition expression. It should then call signal to notify a single waiting thread to resume execution, or broadcast to wake all waiting threads. Signal and broadcast move waiting threads off the condition variable's queue and queue them on the associated lock. Only after the signaling/broadcasting thread releases the lock may these threads resume execution. However, it is possible that other threads were previously waiting on the lock, so the waiting threads are not guaranteed that the condition expression is true. Rather, returning from wait is considered a hint that the expression may have become true. After resuming, the thread must test the expression again before proceeding. Hence, threads commonly wait within a while loop that tests the condition expression.

  25. What are conditional critical regions? What are their limitations, and how can these limitations be overcome?
    Topic: Synchronization

    Conditional critical regions are the regions in a program that must be executed by one process at a time; no other process can execute that region at the same time. When condition variables are used for locking purposes, the critical regions are referred to as conditional critical regions. Their limitations are: with conditional critical regions, waiting occurs without any changes to shared state; the resource concept is unreliable; context switching is inefficient; and the scheduling mechanism is too restrictive. These limitations can be removed using condition variables.

  26. What are condition variables? What are their limitations, and how can these limitations be overcome?
    Topic: Synchronization

    Condition variables are queues of waiting threads. They support three operations: wait, signal and broadcast. Logically, every condition variable is associated with one (or more) Boolean condition expressions and a mutex lock. Condition variables are used to complement locks by allowing a program to specify the order of execution. There are two limitations: (1) the signal operation is explicit, so a programmer may forget to call signal when changing shared state; (2) condition variables do not nest within multiple levels of mutex locks, because only the innermost lock is released when waiting — as a result, deadlock may result if the blocked thread can only be woken by code that acquires a lock still held by the waiting thread. These limits are removed when condition variables are used with transactional memory.

  27. What is the lost wakeup problem, and how can it be resolved?
    Topic: Synchronization

    A signaling or broadcasting transaction may execute concurrently with a transaction that it woke up. If the waking transaction completes before the signaling transaction, it is called the (lost) wakeup problem: the waking transaction may view shared state from before the signaling transaction, and hence from before the logical condition it awaits is visibly changed, so the wakeup is effectively lost. The wakeup problem may be resolved by the deferred signal approach, or by the speculative signal approach.

  28. What are the requirements and implications of the two implementations of condition variables for transactional memory (deferred signal and speculative signal)?
    Topic: Synchronization

    For the deferred signal approach, the requirement and implication is commit actions: signals are deferred and only take effect when the signaling transaction commits, so the implementation must be able to perform actions at commit time. For the speculative signal approach, the requirements and implications are escape actions and robust conflict detection: a waiting transaction may be woken speculatively before the signaler commits, so the system must support escaping the transaction to perform non-transactional actions and must detect conflicts robustly so that a speculative wakeup based on state that is later rolled back can be handled correctly.

  29. Write a bounded-buffer monitor in which the buffers (portions) are embedded within the monitor itself.
    Topic: Synchronization

    monitor bounded_buffer { int items[MAX_ITEMS]; int numItems = 0; condition full, empty; void produce(int v) { while (numItems == MAX_ITEMS) full.wait(); items[numItems++] = v; empty.signal(); } int consume() { int retVal; while (numItems == 0) empty.wait(); retVal = items[--numItems]; full.signal(); return retVal; } }

  30. Explain, in your own words, how the proposed approach manages to avoid deadlocks when unstructured locking is used.
    Topic: Synchronization

    The proposed approach says that deadlock cannot occur when we have the requested lock and its future lock set available. The future lock set is the set of locks acquired from the point where a lock is requested until its matching unlock is found. The approach tracks simple effects (empty sequences of lock/unlock events) and continuation effects (the effect of code on its following expression). Notes are added to lock operations according to their continuation effects; continuation effects are calculated statically, but future lock sets are computed at run time. When a function is called, its continuation effect is pushed on the stack until the call is fully executed, and during this the locks are identified and added to the lock set. At run time, a lock operation proceeds only when its whole future lock set is available to the requesting thread, so a thread never holds one lock while waiting for another in a way that could form a cycle. The approach gives only a single (composite) lock to every lock operation, which increases the degree of parallelism.

  31. How is static analysis performed for this approach, and what are its limitations?
    Topic: Synchronization

    Static analysis is performed in four phases. (1) Pointer analysis: the heap and stack state is formulated at each point of the program by a pointer analysis based on symbolic expressions, treating heap allocation in a context-sensitive manner; the output is a mapping from each expression to a set of abstract locations (formal parameters, global variables or heap-allocated locations). (2) Effect interference: a forward dataflow algorithm runs on the functional control flow graph to compute the effect of each function, propagating output effects to successors until a fixed point is reached. (3) Loops: lock counts in effects flowing from back edges must equal the input effect of the same node, so loop effects can be encoded efficiently from entrance to exit. (4) Effect optimization: common prefixes and suffixes are factored out and nested loops are lifted to reduce the number of branches; the CPU-intensive dataflow algorithm is triggered only for functions known to contain lock operations. Limitations: library code cannot be handled directly (library functions are assumed to have empty effects unless the user adds notes); the analysis cannot handle non-local jumps (including signals) and inline assembly; and the pointer analysis is not capable of handling all programs precisely.

  32. Differentiate between preemptive and non-preemptive scheduling algorithms, and give one example of each.
    Topic: CPU Scheduling

    In non-preemptive (cooperative) scheduling, once a process is given the CPU it keeps it until it terminates or blocks voluntarily (for example, for I/O); the scheduler cannot take the CPU away from it. Example: First-Come First-Served (FCFS). In preemptive scheduling, the operating system can suspend a running process and allocate the CPU to another process, for example when a higher-priority process arrives or a time quantum expires. Example: Round Robin (and Shortest Remaining Time First). Preemptive scheduling improves responsiveness and fairness but needs timer hardware and incurs context-switch overhead, and it requires care with shared data in the kernel.

  33. Consider a variant of round robin 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 the major advantage and disadvantage of this scheme? (c) How would you modify the basic round-robin algorithm to achieve the same effect without duplicate pointers?
    Topic: CPU Scheduling

    (a) In effect, that process will have increased its priority, since by getting time more often it is receiving preferential treatment. (b) The advantage is that more important jobs could be given more time, in other words, higher-priority treatment. The disadvantage, of course, is that shorter (and other) jobs will suffer, receiving a smaller share of the CPU. (c) Allot a longer time quantum to processes deserving higher priority. In other words, have two or more quanta possible in the round-robin scheme.

  34. What is rate-monotonic scheduling? How are priorities assigned in it?
    Topic: CPU Scheduling

    The rate-monotonic scheduling algorithm is a real-time scheduling algorithm that uses preemptive scheduling with static (fixed) priorities. Priorities are assigned inversely to the period of each task — that is, on the basis of the periods — giving higher (better) priority to tasks with shorter periods. Because priorities never change at run time, the algorithm is simple to implement and its schedulability can be analyzed in advance.

  35. Which are the necessary conditions for deadlock to occur?
    Topic: Deadlock

    There are four necessary conditions, and all four of them must hold simultaneously for a deadlock to occur: Mutual Exclusion, Hold and Wait, No Preemption, and Circular Wait. I. Mutual Exclusion means there must be at least one resource which can only be used by a single process at a time (non-shareable mode); if another process requests this resource, it must be delayed until the resource is released. II. Hold and Wait means a process is holding at least one resource and waiting for other resource(s) held by other process(es). III. No Preemption means no process can be forced to release the resources it is holding; resources are released voluntarily. IV. Circular Wait means there is a set of processes such that P0 waits for a resource held by P1, P1 waits for a resource held by P2, and so on up to Pn, which waits for a resource held by P0.

  36. Draw (describe) a resource allocation graph that shows a deadlock condition.
    Topic: Deadlock

    Consider two processes P1 and P2 and two single-instance resources R1 and R2. P1 holds R2 and requests R1 (edges: R2 assigned to P1; P1 waiting for R1). P2 holds R1 and requests R2 (edges: R1 assigned to P2; P2 waiting for R2). The graph contains the cycle P1 -> R1 -> P2 -> R2 -> P1. Since each resource has only one instance, this cycle is a deadlock: P1 can never get R1 until P2 releases it, and P2 can never get R2 until P1 releases it, so neither can proceed.

  37. How is it possible to prevent deadlocks?
    Topic: Deadlock

    There are four necessary conditions which must hold simultaneously for a deadlock to occur, so deadlock can be prevented by implementing some methodology that guarantees that at least one of the four necessary conditions does not hold. Relaxing the first three conditions, i.e. mutual exclusion, hold and wait, and no preemption, is not always useful — it may cause low utilization of resources and starvation. Circular wait is the ultimate choice; it is the most suitable condition to attack, i.e. ensuring that circular wait never holds. The simple methodology used for this purpose is to order all the resources and require that each process always requests resources in increasing order. Hence there may never be a process waiting for a low-numbered resource while holding a higher-numbered resource, ensuring that a cycle is impossible. So, by ensuring there is no circular wait, deadlocks can be prevented.

  38. There are p processes competing for r identical resource units. Each process needs a maximum of m resource units (where m is at most r). (a) Under what condition can no deadlock occur? (b) Give an example of a request sequence leading to deadlock.
    Topic: Deadlock

    (a) In the worst case, every process could be holding m - 1 resources and waiting for one more. Deadlock is therefore impossible if there is at least one extra resource beyond this worst case, i.e. if r is at least p(m - 1) + 1, because then at least one process can obtain all m units it needs, run to completion and release its resources, after which the others can proceed one by one. (b) Suppose p processes each request and are granted m - 1 of the r = p(m - 1) resources, so all resources are allocated. Now every process requests one more resource; none is available, so every process waits. All processes are collectively holding all the resources, all are in the wait state, and no process will ever release its resources — deadlock occurs.

  39. Write a resource allocation algorithm which will prevent deadlock.
    Topic: Deadlock

    A simple deadlock-preventing allocation algorithm for processes requesting identical resources is: If the process has ever acquired any resources before, do not serve the (new) request — the process must first consume and release the resources it already holds. Else, if no resource is remaining free, do not serve the request. Else, if no resource is free at the moment, wait until all resources are free. Otherwise, grant the process access to the resources it needs as one individual (all-at-once) allocation. Because a process receives all the resources it needs in a single grant and never holds some resources while waiting for others, the hold-and-wait condition (and hence deadlock) is prevented.

  40. Three processes are sharing 4 resources of the same type in a system. Every process needs 2 resources. Show that the system is deadlock-free.
    Topic: Deadlock

    If the system were deadlocked, it would imply that each process is holding one resource and is waiting for one more. Since there are 3 processes and 4 resources, even if each of the three processes holds one resource, one resource remains free, so one process must be able to obtain the second resource it needs. This process requires no more resources and therefore it will return its resources when done, after which the remaining processes can also obtain two resources and complete. Hence the system can never be deadlocked.

  41. Suppose that a system is in an unsafe state. Show that it is possible for the processes to complete their execution without entering a deadlock state.
    Topic: Deadlock

    An unsafe state is not the same as a deadlock state: it only means the system cannot guarantee that all processes will complete for every possible sequence of requests. If the processes do not actually request their maximum claims, or if they release resources before requesting more, all of them can still complete. For example, with 12 free resource units in total, suppose P0 holds 5 (max 10), P1 holds 2 (max 4) and P2 holds 2 (max 9), leaving 3 free; the state is unsafe because the remaining need of P0 (5) and P2 (7) cannot both be met safely in some order. But if P1 finishes and releases its 2 units, and P2 then requests and releases resources without ever needing its full maximum at the same time as P0, all three processes can run to completion one after another. So an unsafe state may, but need not, lead to deadlock.

  42. Describe the working of implicit and explicit memory allocators.
    Topic: Dynamic Memory Allocation

    In an implicit allocator, the application allocates memory explicitly (for example with malloc) but freeing is implicit — a garbage collector automatically determines when allocated blocks are no longer used and frees them; the application never calls free. In an explicit allocator, the application is responsible for both allocating and explicitly freeing memory (malloc/free style): it must call free on a block when it is done with it. Explicit allocation is the style used by C, while languages such as Java and Lisp use implicit allocation (garbage collection). A related distinction is between implicit and explicit free lists: an implicit free list scans all blocks (free and allocated) using the block sizes, while an explicit free list links only the free blocks in a list.

  43. If the size of the header and footer is one 4-byte word and no zero-size payload is allowed, find the minimum block size for each case: (a) single-word alignment, both header and footer; (b) single-word alignment, only header; (c) double-word alignment, both header and footer; (d) double-word alignment, only header.
    Topic: Dynamic Memory Allocation

    (a) Single-word alignment, header and footer: minimum payload is one word (4 bytes), so minimum block = 4 (header) + 4 (payload) + 4 (footer) = 12 bytes. (b) Single-word alignment, only header: minimum block = 4 (header) + 4 (payload) = 8 bytes. (c) Double-word alignment, header and footer: the block size must be a multiple of 8 bytes; 4 (header) + payload + 4 (footer) with a payload of at least one word gives 12, which is not a multiple of 8, so the payload must be padded to 8 bytes, giving a minimum block of 16 bytes. (d) Double-word alignment, only header: 4 (header) + 4 (payload) = 8 bytes, which is already a multiple of 8, so the minimum block is 8 bytes.

  44. What is the algorithmic order of the worst-case allocation time and the worst-case freeing time of the following dynamic memory allocation techniques? (a) Implicit free lists (b) Explicit free list, with coalescing while freeing (c) Simple segregated free lists, without coalescing while freeing.
    Topic: Dynamic Memory Allocation

    (a) Implicit free list: allocation requires scanning the blocks of the heap, so worst-case allocation time is linear in the total number of blocks in the heap; freeing (with boundary tags) takes constant time. (b) Explicit free list: allocation searches only the free blocks, so worst-case allocation time is linear in the number of free blocks; freeing, including coalescing with neighbouring free blocks using boundary tags, takes constant time. (c) Simple segregated free lists: allocation only searches the list of one size class, so worst-case allocation time is (near) constant for a request (in the worst case, linear in the number of free blocks in that size class); freeing is constant time, since the block is simply inserted into its size-class list and no coalescing is performed.

  45. What are the difficulties with designing system software?
    Topic: Dynamic Memory Allocation

    Designing system software is difficult because it must run for long periods without failing while managing shared hardware resources for many mutually distrustful programs at once. It must deal with concurrency and synchronization (races and deadlocks), provide protection and security between users and processes, remain efficient because every program depends on it, handle unpredictable asynchronous events such as interrupts, and at the same time present simple, convenient abstractions (files, processes, virtual memory) over complicated, very different hardware. Bugs in system software are especially costly because they can crash or compromise the whole machine rather than a single application.

MIHORA VU – Virtual University Assignment Solutions 2026, Solved Past Papers & All 455+ Courses

Official MIHORA TECH academic repository offering 28,328+ verified study documents for all 455+ Virtual University of Pakistan courses. Access VU Assignment Solution 2026 (Latest Session), Moaaz & Waqar Siddhu solved midterm & final papers, lecture handouts, and quizzes with 100% direct high-speed links.

SPRING 2026 / FALL 2026 ACTIVE SESSION

VU Assignment Solution 2026 (Latest Solved Assignments, GDBs & Quizzes)

Get high-scoring solutions for Assignment 1, Assignment 2, and Graded Discussion Boards across Computer Science, Mathematics, Management, English, and Economics. Compliant with Turnitin similarity limits (< 19%) and official 24-hour grace periods.

Open VU Assignment Solution 2026 Hub →

Popular Virtual University Courses (2026 Solved Papers & Solutions):

CS101 – Introduction to Computing CS201 – Introduction to Programming CS301 – Data Structures CS302 – Digital Logic Design CS401 – Computer Architecture & Assembly Language CS402 – Theory of Automata CS403 – Database Management Systems CS501 – Advance Computer Architecture CS502 – Fundamentals of Algorithms CS504 – Software Engineering - I CS506 – Enterprise Application Development CS601 – Data Communication CS602 – Computer Graphics CS604 – Operating Systems CS605 – Software Engineering - II CS607 – Artificial Intelligence CS610 – Computer Networks CS619 – Final Year Project MTH101 – Calculus & Analytical Geometry MTH202 – Discrete Mathematics MTH301 – Calculus II (Multivariable Calculus) MTH302 – Business Mathematics & Statistics MTH501 – Linear Algebra ENG101 – English Comprehension ENG201 – Business and Technical English Writing MGT101 – Financial Accounting MGT211 – Introduction to Business MGT301 – Principles of Marketing MGT501 – Human Resource Management ACC311 – Fundamentals of Auditing ACC501 – Business Finance STA301 – Statistics and Probability ECO401 – Economics (Micro & Macro) ISL202 – Islamic Studies / Ethics PAK301 – Pakistan Studies PHY101 – Physics - Mechanics & Waves

Complete Directory of All 455 Virtual University Courses & Codes

Browse the complete curriculum of all 455 accredited courses across 27 faculties of Virtual University of Pakistan. Every course includes verified lecture handouts, Moaaz & Waqar Siddhu solved papers, and 2026 assignment solution templates.

Accounting & Finance (16 Courses)

ACC301 – Financial Accounting ACC311 – Fundamentals of Auditing ACC501 – Business Finance BNK601 – Banking Laws & Practices BNK603 – Consumer Banking BNK604 – Commercial Banking BNK610 – Credit & Risk Management in Banking EFIN623 – Economics of Financial Markets FIN611 – Advanced Financial Accounting FIN621 – Financial Statement Analysis FIN622 – Corporate Finance FIN623 – Taxation Management FIN624 – Islamic Banking & Finance FIN625 – Credit & Risk Management FIN630 – Investment Analysis & Portfolio Management FIN722 – Advanced Corporate Finance

Bioinformatics (7 Courses)

BIF101 – Basic Bioinformatics BIF401 – Introduction to Bioinformatics BIF402 – Computational Biology Methods BIF501 – Genomics & Proteomics BIF601 – Bioinformatics Algorithms BIF602 – Structural Bioinformatics BIF604 – Systems Biology

Biological Sciences (16 Courses)

BIO101 – Basic Biology BIO102 – Introductory Biology & Diversity BIO201 – Cell Biology BIO202 – Biochemistry BIO203 – General Genetics BIO204 – Biochemical Techniques BIO301 – Molecular Biology BIO302 – Animal Physiology BIO303 – Developmental Biology BIO401 – Ecology & Evolutionary Biology BIO502 – Immunology & Pathology BIO503 – Pharmacology & Toxicology BIO504 – Applied Microbiology BIO505 – Environmental Biotechnology BIO506 – Forensic Biology BIO731 – Advanced Molecular Genetics

Virtual University of Pakistan (43 Courses)

BNK611 – Economic Ideology in Islam BT613T – Agricultural Biotechnology CS306 – Introduction to Python CS441 – Big Data Concepts CS442 – Introduction to Data Science CS620 – Modeling & Simulation CS701 – Theory of Computation CS703 – Operating Systems CS704 – Advanced Computer Architecture ECO302 – Microeconomics EDU407 – EDU407 ENG401 – Introduction to Literature: Short Story and Poetry GSC201 – Teaching of General Science MCM516 – TV News Reporting and Production MGMT611 – Human Relations MGMT629 – Crisis Management MGT201 – Financial Management MGT401 – Financial Accounting II MGT404 – MGT404 MGT504 – Organization Theory & Design MGT520 – International Business MGT522 – MGT522 MGT601 – SME Management MGT603 – Strategic Management MGT613 – Production and Operations Management MGT703 – Strategic Management MGT705 – Advanced Cost and Management Accounting MGT713 – Production / Operations Management MTH102 – Basic Algebra and Trigonometry MTH201 – Multivariable Calculus MTH304 – Mechanics MTH403 – MTH403 MTH404 – MTH404 MTH405 – MTH405 MTH621 – Real Analysis I MTH633 – Group Theory MTH642 – Fluid Mechanics MTH643 – MTH643 PAK303 – PAK303 PSC401 – Public International Law PSY409 – Positive Psychology SE601 – Software Construction & Development SE602 – Software Re—engineering

Bio-Technology (34 Courses)

BT101 – Ecology, Biodiversity & Evolution BT102 – Microbiology BT201 – Biotechnology Fundamentals BT301 – Recombinant DNA Technology BT302 – Cell and Tissue Culture BT401 – Genetic Engineering BT402 – Fermentation Technology BT403 – Agricultural Biotechnology BT404 – Medical Biotechnology BT405 – Industrial Biotechnology BT406 – Nanobiotechnology BT501 – Biochemical Engineering BT502 – Biosafety & Bioethics BT503 – Molecular Diagnostics BT504 – Stem Cell Technology BT505 – Food Biotechnology BT511 – Vaccine Technology BT512 – Drug Design & Development BT513 – Genomics & Functional Proteomics BT514 – Enzyme Technology BT601 – Advanced Genetic Engineering BT602 – Bioinformatics in Biotechnology BT603 – Bioprocess Engineering BT604 – Aquatic Biotechnology BT605 – Environmental Bioremediation BT611 – Synthetic Biology BT612 – Metabolic Engineering BT613 – Biofuels and Bioenergy BT614 – Clinical Research in Biotechnology BT693 – Research Project in Biotechnology BT732 – Advanced Molecular Biology Seminar BT734 – Advanced Cellular Biotechnology BT735 – Current Topics in Biotechnology NTBT301 – Nanotechnology in Biotechnology

Chemistry (2 Courses)

CHE201 – General Chemistry CHE301 – Organic Chemistry

Computer Science (55 Courses)

CS000 – Introduction to Computer Fundamentals CS001 – Computer Proficiency License CS101 – Introduction to Computing CS201 – Introduction to Programming CS202 – Web Design & Development CS204 – Cyber Law & Intellectual Property CS205 – Information Security Management CS206 – Ethical Hacking & Defense CS301 – Data Structures CS302 – Digital Logic Design CS304 – Object Oriented Programming CS310 – Introduction to Programming (Python) CS311 – Introduction to Web Services Development CS312 – Mobile Application Development CS314 – Embedded Systems & IoT CS315 – Web Engineering CS401 – Computer Architecture & Assembly Language CS402 – Theory of Automata CS403 – Database Management Systems CS405 – Mobile Computing CS407 – Cloud Computing Fundamentals CS408 – Human Computer Interaction CS409 – Ethical & Legal Issues in Computing CS410 – Design & Analysis of Algorithms CS411 – Visual Programming CS420 – Game Design and Development CS432 – Network Security CS435 – Cloud Computing Infrastructure CS501 – Advance Computer Architecture CS502 – Fundamentals of Algorithms CS505 – Agile Software Development CS506 – Enterprise Application Development CS507 – Information Systems CS508 – Modern Programming Languages CS510 – Compiler Construction CS511 – Distributed Systems CS521 – Data Science Principles CS601 – Data Communication CS602 – Computer Graphics CS603 – Software Architecture CS604 – Operating Systems CS606 – Compiler Design & Construction CS607 – Artificial Intelligence CS608 – Digital Signal Processing CS609 – System Programming CS610 – Computer Networks CS614 – Data Warehousing CS619 – Final Year Project CS621 – Information Retrieval Techniques CS625 – Formal Methods in Software Engineering CS627 – Computer Vision & Pattern Recognition CS636 – Big Data Analytics CS708 – Advanced Computer Graphics CS713 – Advanced Software Architecture CS718 – Advanced Artificial Intelligence

Software Engineering (4 Courses)

CS504 – Software Engineering - I CS605 – Software Engineering - II CS611 – Software Quality Assurance CS615 – Software Project Management

Statistics (18 Courses)

DSTA630 – Data Science Research Methods STA000 – Basic Statistics Fundamentals STA100 – Foundations of Statistics STA301 – Statistics and Probability STA304 – Statistical Inference STA404 – Experimental Design STA406 – Sampling Techniques STA408 – Biostatistics and Epidemiology STA630 – Research Methods in Social Sciences STA631 – Advanced Statistical Methods STA632 – Multivariate Analysis STA641 – Non-Parametric Methods STA642 – Econometric Models STA730 – Advanced Research Methodology in Statistics STAT100 – Statistics Fundamentals STAT404 – Applied Statistical Modeling STAT408 – Statistical Computing STAT730 – Advanced Biostatistics

Education (44 Courses)

ECE101 – Introduction to Early Childhood Care & Education EDU101 – Foundations of Education EDU201 – Learning Theories & Applications EDU205 – Classroom Management EDU301 – General Methods of Teaching EDU302 – Human Development & Learning EDU303 – School, Community and Teacher EDU304 – Educational Assessment & Evaluation EDU305 – Curriculum Development & Instruction EDU306 – Contemporary Trends in Education EDU401 – Critical Thinking and Reflective Practices EDU402 – Educational Leadership & Management EDU403 – Art, Craft & Calligraphy in Education EDU404 – Teaching of English EDU405 – Teaching of Mathematics EDU406 – Teaching of General Science EDU410 – ICT in Education EDU411 – Teaching of Social Studies EDU430 – Information & Communication Technology in Teaching EDU431 – Test Development & Measurement EDU433 – Educational Statistics EDU501 – Educational Psychology EDU505 – Guidance and Counseling in Schools EDU510 – Qualitative Research in Education EDU512 – Comparative Education EDU514 – Special Education Principles EDU515 – Early Childhood Education Curriculum EDU516 – Educational Technology & Media EDU601 – Philosophy of Education EDU602 – Educational Planning and Policy EDU604 – Educational Administration & Supervision EDU630 – Research Methods in Education EDU654 – Teacher Education in Pakistan EDU702 – Advanced Seminar in Educational Leadership EDU705 – Advanced Educational Policy Analysis EDUA305 – Applied Curriculum Development EDUA403 – Elementary Arts Education EDUA405 – Pedagogy of Mathematics EDUA516 – Educational Media Design EDUA630 – Action Research in Educational Settings MEDU402 – Master Level Educational Leadership MEDU406 – Science Teaching Pedagogies MEDU430 – Advanced ICT in Education MEDU601 – Advanced Philosophy of Education

Economics (11 Courses)

ECO401 – Economics (Micro & Macro) ECO402 – Microeconomics Analysis ECO403 – Macroeconomics Analysis ECO404 – Managerial Economics ECO406 – Development Economics ECO501 – Monetary Economics ECO601 – International Economics ECO603 – Public Sector Economics ECO606 – Agricultural Economics ECO607 – Environmental & Resource Economics ECO610 – Econometrics Principles

Management Sciences (26 Courses)

EMG525 – Engineering Project Management MGMT614 – Leadership & Team Building MGMT615 – Project Management Practices MGMT617 – Project Management Methodologies MGMT622 – Operations Management MGMT623 – Supply Chain Management MGMT625 – Knowledge Management Systems MGMT627 – Global Business Strategy MGMT628 – Strategic Management MGMT630 – Business Strategy & Policy MGMT631 – Innovation Management MGT101 – Financial Accounting MGT111 – Introduction to Public Administration MGT211 – Introduction to Business MGT301 – Principles of Marketing MGT402 – Cost & Management Accounting MGT411 – Money & Banking MGT501 – Human Resource Management MGT502 – Organizational Behaviour MGT503 – Principles of Management MGT510 – Total Quality Management MGT602 – Entrepreneurship MGT604 – Management of Financial Institutions MGT610 – Business Ethics & Corporate Governance MGT611 – Business & Labor Law MGTE630 – Business Management Strategy

English (34 Courses)

ENG001 – Basic English Grammar & Composition ENG101 – English Comprehension ENG201 – Business and Technical English Writing ENG301 – Business Communication ENG501 – History of English Language ENG502 – Introduction to Linguistics ENG503 – English Morphology and Syntax ENG504 – Sociolinguistics ENG505 – Phonetics & Phonology ENG506 – World Englishes ENG507 – Psycholinguistics ENG508 – Semantics & Pragmatics ENG509 – English for Specific Purposes (ESP) ENG510 – Language Testing & Evaluation ENG511 – Syllabus Design & Materials Development ENG512 – Stylistics & Literary Analysis ENG513 – Second Language Acquisition (SLA) ENG514 – Classical Poetry ENG515 – Classical Drama ENG516 – Research Methodology in Linguistics ENG517 – Modern Poetry ENG518 – Modern Drama ENG519 – Classical Novel ENG520 – Modern Novel ENG521 – American Literature ENG522 – Postcolonial Literature ENG523 – Continental Literature & Criticism ENG524 – Literary Criticism & Theory ENG525 – Discourse Analysis ENG526 – Applied Linguistics in Education ENG527 – Creative Writing & Composition ENG528 – Corpus Linguistics ENG529 – Translation Studies & Theory FENG301 – Functional English for Professionals

Islamic Studies (4 Courses)

ETH100 – Ethics (For Non-Muslim Students) ETH201 – Ethics & Moral Philosophy (For Non-Muslims) ISL201 – Islamic Studies ISL202 – Islamic Studies / Ethics

General Guides (1 Courses)

GENERAL – General University Resources, Guides & Handbooks

General Sciences (1 Courses)

GSC101 – General Science

Human Resources (4 Courses)

HRM613 – Human Resource Development HRM617 – Compensation & Benefits Management HRM624 – Conflict & Negotiation Management HRM627 – Strategic Human Resource Management

Information Technology (4 Courses)

IT430 – E-Commerce & Digital Business IT601 – Network Administration IT602 – Database Administration ITU430 – E-Commerce Systems

Microbiology (4 Courses)

MB501 – General Microbiology & Microbial Diversity MB502 – Microbial Physiology & Metabolism MB504 – Medical Microbiology MIC501 – Applied Microbiology

Mass Communication (22 Courses)

MCD401 – Media Content Development MCD403 – Media Ethics & Professional Standards MCM000 – Introduction to Communication Fundamentals MCM101 – Introduction to Mass Communication MCM301 – Communication Skills MCM304 – Mass Media in Pakistan MCM310 – Radio Broadcasting & Audio Media MCM311 – Radio & Television Production MCM401 – Fundamentals of Public Relations MCM404 – Electronic Media Content Creation MCM411 – News Writing and Reporting MCM431 – Digital Media & Online Journalism MCM501 – Development Support Communication MCM511 – Media Ethics, Cyber Laws & Regulation MCM514 – Feature, Column & Editorial Writing MCM517 – Advertising Strategy & Campaigns MCM520 – Print Media Design & Layout MCM531 – International & Cross-Cultural Communication MCM601 – Theories of Mass Communication MCM604 – Communication Research Methodology MCM610 – Cyber Journalism & Web Publishing MCMP310 – Radio & Audio Production Practical

Marketing (5 Courses)

MKT501 – Marketing Management MKT530 – Consumer Behaviour MKT610 – Customer Relationship Management (CRM) MKT621 – Advertising & Brand Management MKT630 – International Marketing Strategy

Mathematics (20 Courses)

MTH001 – Elementary Mathematics MTH100 – General Mathematics MTH101 – Calculus & Analytical Geometry MTH104 – Sets & Logic MTH202 – Discrete Mathematics MTH301 – Calculus II (Multivariable Calculus) MTH302 – Business Mathematics & Statistics MTH401 – Differential Equations MTH501 – Linear Algebra MTH601 – Operations Research MTH603 – Numerical Analysis MTH622 – Vector & Tensor Analysis MTH631 – Real Analysis MTH632 – Complex Analysis MTH634 – Topology MTH641 – Functional Analysis MTH644 – Mathematical Methods MTH645 – Mechanics MTH646 – Differential Geometry MTH647 – Fluid Mechanics

Social Studies (3 Courses)

PAK301 – Pakistan Studies PAK302 – History of Pakistan PAK522 – Ideology & Constitution of Pakistan

Physics (3 Courses)

PHY000 – Foundational Physics PHY101 – Physics - Mechanics & Waves PHY301 – Circuit Theory

Psychology (23 Courses)

PSY101 – General Psychology PSY401 – Clinical Psychology Fundamentals PSY402 – Social Psychology PSY403 – Developmental Psychology PSY404 – Abnormal Psychology PSY405 – Personality Theories & Assessment PSY406 – Educational Psychology Applications PSY407 – Experimental Psychology & Lab Methods PSY408 – Health Psychology PSY502 – History and Systems of Psychology PSY504 – Cognitive Psychology PSY505 – Psychological Testing & Measurement PSY510 – Positive Psychology & Well-being PSY511 – Counseling Psychology Principles PSY512 – Organizational & Industrial Psychology PSY513 – Neuropsychology Fundamentals PSY515 – Forensic & Criminal Psychology PSY516 – Cross-Cultural Psychology PSY610 – Neurological Basis of Behavior PSY611 – Psychopathology & Diagnostics PSY631 – Psychological Assessment Practicum PSY632 – Research Methods in Psychology PSYP631 – Psychological Assessment Lab Practical

Sociology (14 Courses)

SOC101 – Introduction to Sociology SOC201 – Pakistani Society and Culture SOC301 – Social Psychology & Society SOC302 – Cultural Anthropology SOC401 – Social Research Methods SOC402 – Classical Sociological Theories SOC403 – Social Change & Modernization SOC404 – Urban Sociology SOC601 – Rural Sociology & Community Development SOC602 – Gender Studies & Society SOC605 – Criminology & Juvenile Delinquency SOC608 – Sociology of Development SOC609 – Sociology of Health & Medicine SOC610 – Demography & Population Dynamics

Urdu Literature (2 Courses)

URD101 – Functional Urdu (Urdu Zaban-o-Adab) URDU101 – Urdu Language & Literature

Zoology (35 Courses)

ZOO101 – Principles of Animal Life I ZOO102 – Principles of Animal Life II ZOO103 – Animal Diversity: Invertebrates ZOO111 – Fundamentals of Zoology ZOO201 – Animal Diversity: Chordates ZOO202 – Animal Form & Function I ZOO203 – Animal Form & Function II ZOO301 – Animal Physiology ZOO302 – Cell & Molecular Biology in Zoology ZOO307 – Principles of Ecology ZOO401 – Evolution & Principles of Systematics ZOO403 – Animal Behavior & Sociobiology ZOO404 – Biostatistics for Zoologists ZOO405 – General Developmental Biology ZOO501 – Developmental Biology ZOO502 – Environmental Biology ZOO503 – Biostatistics in Zoological Research ZOO504 – Zoogeography & Paleontology ZOO505 – Wildlife of Pakistan & Conservation ZOO506 – Endocrinology ZOO507 – Animal Diversity & Behavior ZOO509 – Fish Biology & Fisheries Science ZOO510 – General Microbiology & Immunology ZOO511 – Immunology & Serology ZOO512 – Parasitology & Vectors ZOO513 – Applied Entomology ZOO514 – Biochemistry of Animals ZOO515 – Genetics & Population Biology ZOO516 – Aquaculture & Fisheries Management ZOO517 – Toxicology & Environmental Health ZOO518 – Comparative Vertebrate Anatomy ZOO519 – Mammalogy ZOO520 – Ornithology (Bird Biology) ZOO603 – Applied Parasitology & Vector Biology ZOO630 – Research Methodology in Zoology

Core Student Calculators & Rules Handbooks

Frequently Asked Questions – MIHORA VU Study Library

Where can I download VU Assignment Solution 2026 for CS101, CS201, MTH101, and all subjects?

MIHORA VU (https://study.mihora.tech/vu-assignment-solution-2026) offers verified 2026 assignment solutions, GDB answers, quiz files, and Dev-C++ code templates for all 455 Virtual University courses with 100% free direct downloads.

What is the 24-hour assignment grace period in Virtual University?

Virtual University gives students an automatic 24-hour grace period after the official assignment deadline. Submissions during this grace window are awarded full credit with 0 marks deduction.

How to avoid zero marks in VU assignments due to Turnitin plagiarism?

Never copy-paste solutions directly from YouTube or public groups. Keep Turnitin similarity under 19% by renaming code variables, rearranging logical statements, and writing custom explanations.

Where can I get Moaaz and Waqar Siddhu solved midterm and final past papers?

MIHORA VU hosts over 28,328 verified documents including complete Moaaz and Waqar Siddhu past paper collections for all 455 VU subjects, available via direct download without registration.

What is the 20% Two-Half passing rule in Virtual University?

Students must score at least 20% in the First Half (Quizzes, Assignments, GDBs, and Midterms) AND independently at least 20% in the Final Term exam paper to pass any course.