Sponsored Links


Results 1 to 2 of 2

Thread: Problems with the use of semaphore and New definition of semaphore

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    1

    Icon14 Problems with the use of semaphore and New definition of semaphore

    Sponsored Links


    Semaphores
    The main disadvantage of the semaphore discussed in the previous section is that they all
    require busy waiting. While a process is in its critical section, any other process that tries
    to enter its critical section must loop continuously in the entry code. This continual
    looping is clearly a problem in a real multiprogramming system, where a single CPU is
    shared among many processes. Busy waiting wastes CPU cycles that some other process
    may be able to use productively. This type of semaphore is also called a spinlock
    (because the process spins while waiting for the lock)
    . Spinlocks are useful in
    multiprocessor systems. The advantage of a spinlock is that no context switch is required
    when a process must wait on a lock, and a context switch may take considerable time.
    This, when locks are expected to be held for short times, spinlocks are useful.
    To overcome the need for busy waiting, we can modify the definition of semaphore
    and the wait and signal operations on it. When a process executes the wait operation and
    finds that the semaphore value is not positive, it must wait. However, rather than busy
    waiting, the process can block itself. The block operation places a process into a waiting
    queue associated with the semaphore, and the state of the process is switched to the
    waiting state. Then, control is transferred to the CPU scheduler, which selects another
    process to execute.
    A process that is blocked, waiting on a semaphore S, should be restarted when some
    other process executes a signal operation. The process is restarted by a wakeup operation,
    which changes the process from the waiting state to the ready state. The process is then
    placed in the ready queue. (The CPU may or may not be switched from the running
    process to the newly ready process, depending on the CPU scheduling algorithm.)
    Such an implementation of a semaphore is as follows:
    Code:
    typedef struct {
    int value;
    struct process *L;
    } semaphore;
    111
    Each semaphore has an integer value and a list of processes. When a process must
    wait on a semaphore; it is added to the list of processes. A signal operation removes one
    process from the list of the waiting processes and awakens that process. The wait
    operation can be defined as:
    Code:
    void wait(semaphore S) {
    S.value--;
    if(S.value < 0) {
    add this process to S.L;
    block();
    }
    }
    The signal semaphore operation can be defined as
    Code:
    void signal wait(semaphore S) {
    S.value++;
    if(S.value <= 0) {
    remove a process P from S.L;
    wakeup(P);
    }
    }
    The block operation suspends the process that invokes it. The wakeup(P) operation
    resumes the execution of a blocked process P. These two operations are provided by the
    operating system as basic system calls. The negative value of S.value indicates the
    number of processes waiting for the semaphore. A pointer in the PCB needed to maintain
    a queue of processes waiting for a semaphore. As mentioned before, the busy-waiting
    version is better when critical sections are small and queue-waiting version is better for
    long critical sections (when waiting is for longer periods of time).

  2. #2
    A semaphore is an incentive in an assigned place in operating system stockpiling that each procedure can check and afterward change. Contingent upon the esteem that is discovered, online dissertation help uk the procedure can utilize the resource!

    Sponsored Links

  3. Sponsored Links

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Valentines Day Definition In A Few Lines
    By Entboy in forum Gup Shup
    Replies: 0
    Last Post: 01-13-2015, 04:21 PM
  2. Gham ki definition kia Hoti hai
    By viki in forum Gup Shup
    Replies: 0
    Last Post: 11-27-2014, 10:50 PM
  3. Replies: 0
    Last Post: 06-26-2011, 05:55 PM
  4. Definition of sentences.
    By vustudents in forum Announcements
    Replies: 0
    Last Post: 10-19-2010, 11:12 PM
  5. Definition of Itikaf in Ramadan
    By Xpert in forum Islam
    Replies: 0
    Last Post: 08-31-2010, 09:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft