Two Process Solution Using Turn Variable

Duration: 13 min

This video lesson is available to enrolled students.

Return to /learn/COGNIZANT-PREPARATION/operating-systems/process-synchronization/two-process-solutions/asset-two-process-solution-using-turn-variable after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Communication Round: Vocabulary, Subject Verb Agreement (Verb Noun Agreement), Tenses, Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Cloze Test (Cloze Passage), Sentence Correction (Error Correction), Sentence Completion (Fill in the blanks), Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Direct and Indirect Speech, Active Passive Voice (Voice), Verbal Analogy (Word Based Analogy), Articles, Preposition, Conjunction, Sentence Construction, English Writing Ability, Communication Assessment
  2. Quantitative Aptitude: Ratio and Proportion (Ratios), Divisibility Rules, Data Interpretation, Mixture and Alligation, Permutation and Combination, Logarithm, Number System, HCF LCM, Speed Time and Distance, Percentage, Average, Powers and Exponents (Surds and Indices), Time and Work, Mensuration and Geometry, Age Problems, Pipe and Cistern, Probability, Profit and Loss, Simple Interest and Compound Interest, Algebra
  3. Analytical and Logical Reasoning: Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Directions (Direction Test), Ranking, Order and Sequence, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Selection Decision Table (Decision Making), Logical Sequence Of Words, Puzzle Solving (Puzzles), Syllogisms, Seating Arrangements, Calendar, Clock, Blood Relations, Cubes & Dices, Venn Diagram, Analytical Reasoning (Counting Figures Reasoning)
  4. Cognizant Gaming Aptitude: Gamified / Game Based Aptitude
  5. Java (Cluster 1): Java
  6. ANSI SQL MySQL (Cluster 1,2,3): SQL
  7. HTML, CSS, JavaScript (Cluster 1,3): HTML, CSS, JavaScript
  8. Python (Cluster 2): Python for Placements by Yash Sir
  9. Cloud Fundamentals (Cluster 2): Emerging Tech Trends
  10. C# (Cluster 3): C#
  11. OOPs: Object Oriented Programming (OOPS)
  12. Technical Assessment (Coding): Coding Questions by Yash Sir, C Programming by Yash Sir, Programming in C++, Pseudo Codes
  13. Data Structures: Introduction to DS, Array, Stack, Queue, Linked List, Tree, Graphs, Hashing
  14. DBMS: Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, File Organization & Indexing, Relational Algebra, Relational Calculus, Transaction Management, Concurrency Control, Database Recovery, ORDBMS, Database Security & Authorization, Query Processing & Optimization, Enhanced Data Models, Data Warehousing & Mining, Big Data Systems, NoSQL
  15. Operating Systems: Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Deadlock, Threads & Process Creation, Memory Management, Virtual Memory, Disc Scheduling, File Management, Windows OS, Linux OS, Security, Distributed Systems, Virtual Machines
  16. Computer Networks: Introduction to CN, Data Communication, DLL: Access Control, DLL: Flow Control, DLL: Error Control, DLL: Framing, Data Link Layer - Ethernet, Net Layer: IPv4 & Proto, Net Layer: IP Addressing, Net Layer:Routing Protocol, Transport Layer Services, TL: Congestion & UDP, Application Layer, Hardware basics, Network Security, Mobile Technology, Cloud Computing and IoT, Cyber and Info Security
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This educational video lecture, presented by Sanchit Jain Sir from Knowledge Gate, focuses on the 'Solutions to Critical Section Problem' in Operating Systems. The instructor systematically categorizes these solutions into four main types: Two Process Solution, Operating System Solution, Hardware Solution, and Computer and Programming Support Type. He details specific methods within each category, such as Peterson's Solution, Semaphores, and Monitors. The latter half of the lecture transitions into a deep dive into the 'Two Process Solution' using a Boolean variable named 'turn', analyzing the code structure for two processes (P0 and P1) and explaining the logic of mutual exclusion and strict alternation.

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The video begins with a slide titled 'Solutions to Critical Section Problem'. The instructor introduces the four general categories of solutions. The first category is 'Two Process Solution', which includes 'Using Boolean variable turn', 'Using Boolean array flag', and 'Peterson's Solution'. He circles 'Peterson's Solution' to highlight it. The second category is 'Operating System Solution', listing 'Counting Semaphore' and 'Binary Semaphore'. The third is 'Hardware Solution', listing 'Test and Set Lock' and 'Disable interrupt'. The fourth is 'Computer and Programming Support Type', listing 'Monitors'. The instructor uses a pen to check off items as he introduces them, establishing the roadmap for the lecture.

  2. 2:00 – 5:00 02:00-05:00

    Continuing the overview, the instructor places checkmarks next to 'Counting Semaphore' and 'Binary Semaphore' under the Operating System Solution section. He then moves to the Hardware Solution, checking off 'Test and Set Lock' and 'Disable interrupt'. Finally, he checks 'Monitors' under the Computer and Programming Support Type. Throughout this segment, he gestures towards the screen, emphasizing that these are the standard approaches used to solve the critical section problem. The slide remains visible, providing a clear reference for the classification of synchronization mechanisms.

  3. 5:00 – 10:00 05:00-10:00

    The slide changes to a specific example titled 'Here we will use a Boolean variable turn, which is initialize randomly(0/1)'. A table displays code for two processes, P0 and P1. For P0, the code is `while (1) { while (turn!= 0); Critical Section turn = 1; Remainder section }`. For P1, it is `while (1) { while (turn!= 1); Critical Section turn = 0; Remainder Section }`. The instructor explains that the variable `turn` is initialized randomly to either 0 or 1. He writes 'turn = 0' or 'turn = 1' at the top of the table to illustrate the initialization state. He begins to explain the logic where P0 waits for `turn` to be 0 before entering the Critical Section.

  4. 10:00 – 13:22 10:00-13:22

    The instructor elaborates on the 'Boolean variable turn' solution. He draws arrows and circles to demonstrate the flow of execution. He explains that if `turn` is 0, P0 enters the Critical Section, executes its code, and then sets `turn = 1` before moving to the Remainder section. Conversely, P1 waits while `turn != 1`. He draws a loop for P1 indicating it waits until the condition is met. He highlights that this mechanism enforces strict alternation between the two processes. He points out that while this satisfies mutual exclusion, it may fail the progress requirement if a process is in the remainder section and the turn variable is not set correctly for it to enter again.

The lecture provides a structured overview of synchronization solutions, moving from a high-level classification to a specific algorithmic implementation. The instructor effectively uses visual aids like checkmarks and code snippets to categorize solutions into Two Process, OS, Hardware, and Programming types. The detailed analysis of the 'Boolean variable turn' solution demonstrates how strict alternation is achieved through a shared variable, serving as a foundational example for understanding more complex synchronization primitives like semaphores and monitors discussed in the initial overview.

Loading lesson…