Two Process Solution Using Turn Variable

Duration: 13 min

This video lesson is available to enrolled students.

Return to /learn/AMCAT-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. Quantitative Ability: Percentage, Profit and Loss, Ratio and Proportion (Ratios), Average, Time and Work, Speed Time and Distance, Simple Interest and Compound Interest, Age Problems, Number System, Divisibility Rules, HCF LCM, Algebra, Permutation and Combination, Probability, Data Interpretation, Logarithm, Sequence and Series (Series), Powers and Exponents (Surds and Indices), Speed Mathematics and Basic Mathematics
  2. Logical Reasoning: Seating Arrangements, Puzzle Solving (Puzzles), Data Arrangement, Coding Decoding, Blood Relations, Directions (Direction Test), Ranking, Order and Sequence, Data Sufficiency, Venn Diagram, Inequality, Series (Number and Letter Series) (Numerical Relations and Reasoning), Logical Sequence Of Words, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Selection Decision Table (Decision Making), Analogy, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning)
  3. Verbal Ability: Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Subject Verb Agreement (Verb Noun Agreement), Tenses, Articles, Preposition, Conjunction, Modals, Active Passive Voice (Voice), Direct and Indirect Speech, Vocabulary, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Sentence Completion (Fill in the blanks), Sentence Correction (Error Correction), Cloze Test (Cloze Passage), Facts, Inference and Judgements
  4. Programming Fundamentals (Technical): C Fundamentals
  5. Data Structures (Technical): Introduction to DS, Array, Stack, Queue, Linked List, Tree, Graphs, Hashing
  6. Algorithms (Technical): Algorithm Analysis, Sorting Algorithms, Greedy Algorithms, Dynamic Programming, Minimum Spanning Trees, Shortest Path Algos, Time Complexity Analysis, Advanced Algorithms
  7. OOPs (Technical): Object Oriented Programming (OOPS)
  8. DBMS (Technical): 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
  9. SQL (Technical): SQL
  10. Operating Systems (Technical): 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
  11. Computer Networks (Technical): 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
  12. Software Engineering (Technical): Fundamentals of Software Engineering, Software Requirements and Quality Assurance, Software Design, Estimation and Metrics, Software Testing, Software Maintenance and Configuration Management
  13. Coding/Automata Round: Coding Questions by Yash Sir, C Programming by Yash Sir, Programming in C++, Java, Python for Placements by Yash Sir, Pseudo Codes
  14. Personality / Behavioral Assessment: Behavioral Assessment (Behavioral Competency Profiling) (Psychometric Test)
  15. Writing Assessment: English Writing Ability
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…