CS604 (Lec 19 - 45) Highlighted handots by Masters .pdf

Verified academic study resource for CS604 (Operating Systems) under the Computer Science at Virtual University of Pakistan. This PDF document (Verified Study Resource) covers Full Course Curriculum spanning approximately 280 pages across 8 curriculum modules, and is indexed for student examination review with instant in-browser preview and 100% free direct download.

Course
CS604 – Operating Systems
Faculty
Computer Science
Format
PDF
Type
Study Resource
Coverage
Full Course Curriculum

Review this document alongside the official handouts and test your retention in the Interactive MCQs Studio.

What this file covers — CS604 syllabus roadmap

  1. Core Architecture, Syntax & Primitive Data Structures — Lectures 1 to 6 (Pages 1 to 65). 15% Objective Marks (8–10 MCQs)
  2. Conditional Branching, Loops & Logical Control Flow — Lectures 7 to 12 (Pages 66 to 140). 18% Exam Marks (MCQs + 2-Mark Short Questions)
  3. Memory Management, Pointers, Arrays & Functions — Lectures 13 to 18 (Pages 141 to 215). 22% Exam Marks (High Yield for Midterms)
  4. Midterm Consolidation, Strings & Algorithm Synthesis — Lectures 19 to 22 (Pages 216 to 280). Midterm Exam Culmination (Lectures 1–22 Scope)
  5. Object-Oriented Paradigms: Classes & Data Abstraction — Lectures 23 to 29 (Pages 281 to 360). 16% Final-Term Marks (Core OO Concepts)
  6. Inheritance Hierarchies & Dynamic Polymorphism — Lectures 30 to 36 (Pages 361 to 435). 20% Final-Term Marks (Virtual Functions & V-Tables)
  7. Templates, Standard Library & Persistent File I/O — Lectures 37 to 41 (Pages 436 to 510). 14% Final-Term Marks (Generic Code & Streams)
  8. Final-Term Examination Dossier & Capstone Synthesis — Lectures 42 to 45 (Pages 511 to 585). Final-Term Exam Synthesis (Lectures 23–45 Scope)

Frequently asked questions

Where can I download CS604 (Lec 19 - 45) Highlighted handots by Masters .pdf for free?

You can preview and download "CS604 (Lec 19 - 45) Highlighted handots by Masters .pdf" (CS604 PDF, ~280 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs604-lec-19-45-highlighted-handots-by-masters-pdf) with 100% free high-speed downloads and zero registration requirements.

What syllabus chapters and lectures are covered in this CS604 file?

This document covers Full Course Curriculum across 8 distinct lecture units (Lectures 1 to 6, Lectures 7 to 12, Lectures 13 to 18, Lectures 19 to 22, Lectures 23 to 29, Lectures 30 to 36, Lectures 37 to 41, Lectures 42 to 45), featuring comprehensive definitions, solved objective questions, and examiner marking rubrics.

What is the passing criteria for CS604 under the VU 20% Two-Half Rule?

Under official Virtual University regulations, students must score at least 20% in the First Half (Quizzes, Assignments, GDBs, and Midterm combined) AND independently at least 20% in the Final-Term examination paper. Scoring under 20% in the final exam results in an automatic F grade regardless of earlier marks.

Are CS604 solved past papers and handouts verified for 2026 exams?

Yes. All CS604 materials on MIHORA VU—including Moaaz, Waqar Siddhu, and team archives—are reviewed against the current VU syllabus to help students prepare for 2026 Midterm, Final-Term, and online quiz examinations.

Inside this file

Operating Systems [CS-604]                                            Lecture No. 18 and 19

  Operating Systems
  Lecture No. 18 and 19
  Reading Material
         Chapter 7 of the textbook
         Lectures 18 and 19 on Virtual TV

  Summary
         Process Synchronization: the basic concept
         The Critical Section Problem
         Solutions for the Critical Section Problem
         2-Process Critical Section Problem solutions

  Process Synchronization
  Concurrent processes or threads often need access to shared data and shared resources. If
  there is no controlled access to shared data, it is often possible to obtain an inconsistent
  state of this data. Maintaining data consistency requires mechanisms to ensure the orderly
  execution of cooperating processes, and hence various process synchronization methods
  are used. In the producer-consumer problem that was discussed earlier, the version only
  allows one item less than the buffer size to be stored, to provide a solution for the buffer
  to use its entire capacity of N items is not simple. The producer and consumer share data
  structure ‘buffer’ and use other variables shown below:

                      #define BUFFER_SIZE 10
                      typedef struct
                      {
                        ...
                      } item;
                      item buffer[BUFFER_SIZE];
                      int in=0;
                      int out=0;

     The code for the producer process is:

          while(1)
          {
             /*Produce an item in nextProduced*/
             while(counter == BUFFER_SIZE); /*do nothing*/
             buffer[in]=nextProduced;
             in=(in+1)%BUFFER_SIZE;
             counter++;
          }

                                                                                           95

   The code for the consumer process is:

              while(1)
              {
                 while(counter==0); //do nothing
                 nextConsumed=buffer[out];
                 out=(out+1)%BUFFER_SIZE;
                 counter--;
                 /*Consume the item in nextConsumed*/
              }

Both producer and consumer routines may not execute properly if executed concurrently.
Suppose that the value of the counter is 5, and that both the producer and the consumer
execute the statement counter++ and counter- - concurrently. Following the execution of
these statements the value of the counter may be 4,5,or 6! The only correct result of these
statements should be counter= =5, which is generated if the consumer and the producer
execute separately. Suppose counter++ is implemented in machine code as the following
instructions:
MOV    R1, counter
INC    R1
MOV    counter, R1
whereas counter- - maybe implemented as:
MOV    R2, counter
DEC    R2
MOV    counter, R2
    If both the producer and consumer attempt to update the buffer concurrently, the
machine language statements may get interleaved. Interleaving depends upon how the
producer and consumer processes are scheduled. Assume counter is initially 5. One
interleaving of statements is:
producer: MOV         R1, counter           (R1 = 5)
          INC         R1                    (R1 = 6)
consumer: MOV         R2, counter           (R2 = 5)
          DEC         R2                    (R2 = 4)
producer: MOV         counter, R1           (counter = 6)
consumer: MOV         counter, R2           (counter = 4)
The value of count will be 4, where the correct result should be 5. The value of count
could also be 6 if producer executes MOV counter, R1 at the end. The reason for this
state is that we allowed both processes to manipulate the variable counter concurrently.
A situation like this, where several processes access and manipulate the same data
concurrently and the outcome of the manipulation depends on the particular order in
which the access takes place, is called a race condition. To guard against such race
conditions, we require synchronization of processes.
    Concurrent transactions in a bank or in an airline reservation (or travel agent) office
are a couple of other examples that illustrates the critical section problem. We show

                                                                                        96

interleaving of two bank transactions, a deposit and a withdrawal. Here are the details of
the transactions:
       Current balance = Rs. 50,000
       Check deposited = Rs. 10,000
       ATM withdrawn = Rs. 5,000
The codes for deposit and withdrawal are shown in Figure 18.1.

         D                       Balance                           W

     DEPOSIT                                     WITHDRAWAL
     MOV A, Balance                              MOV B, Balance
     ADD A, Deposited                            SUB  B, Withdrawn
     MOV Balance, A                              MOV Balance, B

Figure 18.1 Bank transactions—deposit and withdrawal
     Here is what may happen if the two transactions are allowed to execute concurrently,
i.e., the transactions are allowed to interleave. Note that in this case the final balance will
be Rs. 45,000, i.e., a loss of Rs. 5,000. If MOV Balance,A executes at the end, the
result will be a gain of Rs. 5,000. In both cases, the final result is wrong.

             Check Deposit:
                      MOV A, Balance                   // A = 50,000
                      ADD A, Deposited                 // A = 60,000
             ATM Withdrawal:
                      MOV B, Balance                   // B = 50,000
                      SUB B, Withdrawn                 // B = 45,000
             Check Deposit:
                      MOV Balance, A                   // Balance = 60,000
             ATM Withdrawal:
                      MOV Balance, B                   // Balance = 45,000

The Critical Section Problem
Critical Section: A piece of code in a cooperating process in which the process may
updates shared data (variable, file, database, etc.).
Critical Section Problem: Serialize executions of critical sections in cooperating
processes.

More CS604 files

All CS604 files · Midterm Prep 2026 · MCQs Bank