EmbLogic's Blog

Implementing Semaphore in a single process by setting its initial value to ZERO

  • RCS file: test1.c,v
    Working file: test1.c
    head: 1.6
    branch:
    locks: strict
    raghav: 1.6
    access list:
    symbolic names:
    keyword substitution: kv
    total revisions: 6;    selected revisions: 6
    description:
    Implementing semaphore in a single process to check what if …we set the value of a semaphore directly to 0.
    —————————-
    revision 1.6    locked by: raghav;
    date: 2014/01/28 14:42:29;  author: raghav;  state: Exp;  lines: +3 -1
    Run the program and analyse its output by changing the semaphore from 0 to 1.
    —————————-
    revision 1.5
    date: 2014/01/28 14:36:22;  author: raghav;  state: Exp;  lines: +19 -0
    now. . write two statements in a program.. one before using the wait function and one after using the wait function.
    print the value of semaphore using GETVAL before using wait function.
    and print the value of semaphore using GETVAL after using wait function i.e. in critical reigon.
    make sure one thing if you’ve set the initial value of semaphore to ZERO, then it will not enter the critical region.
    —————————-
    revision 1.4
    date: 2014/01/28 14:16:51;  author: raghav;  state: Exp;  lines: +7 -1
    after creating the semaphore : set its value to 0(zero)
    —————————-
    revision 1.3
    date: 2014/01/28 10:39:02;  author: raghav;  state: Exp;  lines: +4 -0
    Second use a semctl function to set its value to 0 rather than 1, because we are checking what will happen if we directly set its value to 0
    —————————-
    revision 1.2
    date: 2014/01/28 10:37:18;  author: raghav;  state: Exp;  lines: +9 -0
    First creating a semaphore using a semget function .
    —————————-
    revision 1.1
    date: 2014/01/28 10:34:38;  author: raghav;  state: Exp;
    Initial revision
    =============================================================================

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>