Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 977
  • Last Modified:

sem_open and sem_getvalue

Hi,

   I have a program that does the following:

mysem = sem_open(semname, O_CREAT, 0644, 10);
sem_getvalue(mysem, &myvalue);
printf("%i", myvalue);

Very simple:
 it creates a semaphore with value 10, gets the value, and prints it out.

The problem is:
  As you can see I set the value to 10
  However, the output for the value is 1.

Why is it telling me that the semaphore has a value of 1 when I explicitly initialized it to 10?
0
jameswalt
Asked:
jameswalt
1 Solution
 
efnCommented:
I don't see anything obviously wrong.  Try checking the return values from the calls to sem_open and sem_getvalue.  Maybe one or both failed.
0
 
Mamata_gdCommented:
Also check if there is object with same name semname. BTW, what is 0644???
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now