Two Process Solution Using Turn Variable

Duration: 13 min

This video lesson is available to enrolled students.

Return to /learn/ISRO/operating-system/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. About Course: About the Course
  2. General Aptitude & Reasoning: Number System, Percentage, Ratio and Proportion (Ratios), Average, Profit and Loss, Simple Interest and Compound Interest, Time and Work, Speed Time and Distance, Mixture and Alligation, Data Interpretation, Algebra, Probability, Permutation and Combination, Venn Diagram, HCF LCM, Divisibility Rules, Age Problems, Pipe and Cistern, Partnership, Linear Algebra, Sequence and Series (Series), Statistics, Powers and Exponents (Surds and Indices), Arithmetic, Mensuration and Geometry, Calculus, Trigonometry, Vectors, Speed Mathematics and Basic Mathematics, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Analogy, Series (Number and Letter Series) (Numerical Relations and Reasoning), Puzzle Solving (Puzzles), Syllogisms, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Calendar, Seating Arrangements, Coding Decoding, Blood Relations, Directions (Direction Test), Clock, Analytical Reasoning (Counting Figures Reasoning), Ranking, Order and Sequence, Logical Sequence Of Words, Inequality, Data Sufficiency, Cubes & Dices
  3. Computer Networks & Cybersecurity: 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
  4. Programming, Data Structures & Algorithms: C Fundamentals, Control Flow, Functions, Arrays & Pointers, Storage Classes, Structures & Enums, DMA, Macros, Scoping & File Handling, OOPS with C++, Introduction to DS, Array, Stack, Queue, Linked List, Tree, Graphs, Hashing, Algorithm Analysis, Time Complexity Analysis, Sorting Algorithms, Greedy Algorithms, Dynamic Programming, Minimum Spanning Trees, Shortest Path Algos, Advanced Algorithms
  5. AI, Machine Learning, Big Data & Cloud: Emerging Tech Trends, Artificial Intelligence, Big Data Systems, Approaches to AI, Search Algorithms, Knowledge Representation, Cloud Computing
  6. Digital Logic & Computer Organization: Digital Systems & Boolean Basics, Logic Gates & Hardware, Boolean Expression, Boolean Minimization, Combinational Circuit, Sequential Circuits, Number System, Number Representation, Basics of COA, Floating Point Rep, Cache Memory Organization, Input Output Organisation, Pipelining, Instr Formats & Modes, Register Transfer and Microoperations, Control Unit Design, Programming the Basic Computer
  7. TOC & Compiler: Introduction to TOC, Deterministic FA (DFA), Non-Deterministic FA, Regular Expressions, Grammar, Regular Language Properties, Moore & Mealy Machines, Pushdown Automata & CFG, Turing Machines, Complexity Theory, Intro to Compilers, Lexical Analysis, Grammar & CFG, Syntax Analysis: Top-Down, Syntax Analysis: Bottom-Up, Semantic Analysis & SDT, Intermediate Code Gen, Code Optimization, Run Time Environment
  8. Discrete Mathematics: Set Theory, Relations, Functions, Graph Theory, Group Theory, Propositional and Predicate Logic
  9. Operating System: Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Threads & Process Creation, Deadlock, Memory Management, Virtual Memory, Disc Scheduling, File Management, Unix OS, Linux OS, Distributed Systems
  10. Software Engineering: Fundamentals of Software Engineering, Software Requirements and Quality Assurance, Software Design, Estimation and Metrics, Software Testing, Software Maintenance and Configuration Management, Object Oriented Technology, HTML Basics, JavaScript-Basics, Java, XML
  11. Database Management System: Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, File Organization & Indexing, Relational Algebra, SQL, Relational Calculus, Transaction Management, Concurrency Control, Database Recovery, Data Warehousing & Mining, Enhanced Data Models, NoSQL
  12. Other Recurring CS Topics: Basics of Computer Graphics, 2-D Geometrical Transforms and Viewing, Multimedia
  13. Live Classes: ISRO Live classes
  14. Full Mock Test:
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…