OneStopGate.Com
OnestopGate   OnestopGate
   Sunday, December 22, 2024 Login  
OnestopGate
Home | Overview | Syllabus | Tutorials | FAQs | Downloads | Recommended Websites | Advertise | Payments | Contact Us | Forum
OneStopGate

GATE Resources
Gate Articles
Gate Books
Gate Colleges 
Gate Downloads 
Gate Faqs
Gate Jobs
Gate News 
Gate Sample Papers
Training Institutes

GATE Overview
Overview
GATE Eligibility
Structure Of GATE
GATE Coaching Centers
Colleges Providing M.Tech/M.E.
GATE Score
GATE Results
PG with Scholarships
Article On GATE
Admission Process For M.Tech/ MCP-PhD
GATE Topper 2012-13
GATE Forum




GATE 2025 Exclusive
Organizing Institute
Important Dates
How to Apply
Discipline Codes
GATE 2025 Exam Structure

GATE 2025 Syllabus
Aerospace Engg..
Agricultural Engg..
Architecture and Planning
Chemical Engg..
Chemistry
Civil Engg..
Computer Science / IT
Electronics & Communication Engg..
Electrical Engg..
Engineering Sciences
Geology and Geophysics
Instrumentation Engineering
Life Sciences
Mathematics
Mechanical Engg..
Metallurgical Engg..
Mining Engg..
Physics
Production & Industrial Engg..
Pharmaceutical Sciences
Textile Engineering and Fibre Science

GATE Study Material
Aerospace Engg..
Agricultural Engg..
Chemical Engg..
Chemistry
Civil Engg..
Computer Science / IT
Electronics & Communication Engg..
Electrical Engg..
Engineering Sciences
Instrumentation Engg..
Life Sciences
Mathematics
Mechanical Engg..
Physics
Pharmaceutical Sciences
Textile Engineering  and Fibre Science

GATE Preparation
GATE Pattern
GATE Tips N Tricks
Compare Evaluation
Sample Papers 
Gate Downloads 
Experts View

CEED 2013
CEED Exams
Eligibility
Application Forms
Important Dates
Contact Address
Examination Centres
CEED Sample Papers

Discuss GATE
GATE Forum
Exam Cities
Contact Details
Bank Details

Miscellaneous
Advertisment
Contact Us


Home » GATE Study Material » Computer Science & IT » Operating System » About the Operating System

Opertaing System

Looking for GATE Preparation Material? Join & Get here now!

** Gate 2013 Question Papers.. ** CEED 2013 Results.. ** Gate 2013 Question Papers With Solutions.. ** GATE 2013 CUT-OFFs.. ** GATE 2013 Results.. **

<<Previous Next>>
Overview Of Thread Continue...


  • A lock can be in one of two states: locked and unlocked. Semantics of lock operations:
    • Lock(name) : creates a lock that starts out in the unlocked state.
    • Acquire() : Atomically waits until the lock state is unlocked, then sets the lock state to locked.
    • Release() : Atomically changes the lock state to unlocked from locked.
    In assignment 1 you will implement locks in Nachos on top of semaphores.
  • What are requirements for a locking implementation?
    • Only one thread can acquire lock at a time. (safety)
    • If multiple threads try to acquire an unlocked lock, one of the threads will get it. (liveness)
    • All unlocks complete in finite time. (liveness)
  • What are desirable properties for a locking implementation?
    • Efficiency: take up as little resources as possible.
    • Fairness: threads acquire lock in the order they ask for it. Are also weaker forms of fairness.
    • Simple to use.
  • When use locks, typically associate a lock with pieces of data that multiple threads access. When one thread wants to access a piece of data, it first acquires the lock. It then performs the access, then unlocks the lock. So, the lock allows threads to perform complicated atomic operations on each piece of data.
  • Can you implement unbounded buffer only using locks? There is a problem - if the consumer wants to consume a piece of data before the producer produces the data, it must wait. But locks do not allow the consumer to wait until the producer produces the data. So, consumer must loop until the data is ready. This is bad because it wastes CPU resources.
  • There is another synchronization abstraction called condition variables just for this kind of situation. Here is the Nachos interface:
    class Condition {
    public:
      Condition(char* debugName);
      ~Condition();
      void Wait(Lock *conditionLock);
      void Signal(Lock *conditionLock);
      void Broadcast(Lock *conditionLock);
    }
    
  • Semantics of condition variable operations:
    • Condition(name) : creates a condition variable.
    • Wait(Lock *l) : Atomically releases the lock and waits. When Wait returns the lock will have been reacquired.
    • Signal(Lock *l) : Enables one of the waiting threads to run. When Signal returns the lock is still acquired.
    • Broadcast(Lock *l) : Enables all of the waiting threads to run. When Broadcast returns the lock is still acquired.
    All locks must be the same. In assignment 1 you will implement condition variables in Nachos on top of semaphores.
  • Typically, you associate a lock and a condition variable with a data structure. Before the program performs an operation on the data structure, it acquires the lock. If it has to wait before it can perform the operation, it uses the condition variable to wait for another operation to bring the data structure into a state where it can perform the operation. In some cases you need more than one condition variable.
  • Let's say that we want to implement an unbounded buffer using locks and condition variables. In this case we have 2 consumers.
    Lock *l;
    Condition *c;
    int avail = 0;
    void consumer(int dummy) {
    while (1) {
      l->Acquire();
      if (avail == 0) {
    	c->Wait(l);
      }
      consume the next unit of data
      avail--;
      l->Release();
    }
    }
    void producer(int dummy) {
    while (1) {
      l->Acquire();
      produce the next unit of data
      avail++;
      c->Signal(l);
      l->Release();
    }
    }
    void main() {
    l = new Lock("l");
    c = new Condition("c");
    Thread *t = new Thread("consumer");
    t->Fork(consumer, 1);
    Thread *t = new Thread("consumer");
    t->Fork(consumer, 2);
    t = new Thread("producer");
    t->Fork(producer, 1);
    }
    
  • <<Previous Next>>



    Discussion Center

    Discuss/
    Query

    Papers/
    Syllabus

    Feedback/
    Suggestion

    Yahoo
    Groups

    Sirfdosti
    Groups

    Contact
    Us

    MEMBERS LOGIN
      
    Email ID:
    Password:

      Forgot Password?
     New User? Register!

    INTERVIEW EBOOK
    Get 9,000+ Interview Questions & Answers in an eBook. Interview Question & Answer Guide
    • 9,000+ Interview Questions
    • All Questions Answered
    • 5 FREE Bonuses
    • Free Upgrades
    GATE RESOURCES
     
  • Gate Books
  • Training Institutes
  • Gate FAQs
  • GATE BOOKS
     
  • Mechanical Engineeering Books
  • Robotics Automations Engineering Books
  • Civil Engineering Books
  • Chemical Engineering Books
  • Environmental Engineering Books
  • Electrical Engineering Books
  • Electronics Engineering Books
  • Information Technology Books
  • Software Engineering Books
  • GATE Preparation Books
  • Exciting Offers



    GATE Exam, Gate 2009, Gate Papers, Gate Preparation & Related Pages


    GATE Overview | GATE Eligibility | Structure Of GATE | GATE Training Institutes | Colleges Providing M.Tech/M.E. | GATE Score | GATE Results | PG with Scholarships | Article On GATE | GATE Forum | GATE 2009 Exclusive | GATE 2009 Syllabus | GATE Organizing Institute | Important Dates for GATE Exam | How to Apply for GATE | Discipline / Branch Codes | GATE Syllabus for Aerospace Engineering | GATE Syllabus for Agricultural Engineering | GATE Syllabus for Architecture and Planning | GATE Syllabus for Chemical Engineering | GATE Syllabus for Chemistry | GATE Syllabus for Civil Engineering | GATE Syllabus for Computer Science / IT | GATE Syllabus for Electronics and Communication Engineering | GATE Syllabus for Engineering Sciences | GATE Syllabus for Geology and Geophysics | GATE Syllabus for Instrumentation Engineering | GATE Syllabus for Life Sciences | GATE Syllabus for Mathematics | GATE Syllabus for Mechanical Engineering | GATE Syllabus for Metallurgical Engineering | GATE Syllabus for Mining Engineering | GATE Syllabus for Physics | GATE Syllabus for Production and Industrial Engineering | GATE Syllabus for Pharmaceutical Sciences | GATE Syllabus for Textile Engineering and Fibre Science | GATE Preparation | GATE Pattern | GATE Tips & Tricks | GATE Compare Evaluation | GATE Sample Papers | GATE Downloads | Experts View on GATE | CEED 2009 | CEED 2009 Exam | Eligibility for CEED Exam | Application forms of CEED Exam | Important Dates of CEED Exam | Contact Address for CEED Exam | CEED Examination Centres | CEED Sample Papers | Discuss GATE | GATE Forum of OneStopGATE.com | GATE Exam Cities | Contact Details for GATE | Bank Details for GATE | GATE Miscellaneous Info | GATE FAQs | Advertisement on GATE | Contact Us on OneStopGATE |
    Copyright © 2024. One Stop Gate.com. All rights reserved Testimonials |Link To Us |Sitemap |Privacy Policy | Terms and Conditions|About Us
    Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | India Job Forum | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Free Classifieds | Jobs Assist | Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Web Hosting | Quick Site Kit | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Software Testing Interview Questions | Free Online Exams | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World
    C Interview Questions | C++ Interview Questions | Send Free SMS | Placement Papers | SMS Jokes | Cool Forwards | Romantic Shayari