Solved

sem_open and sem_getvalue

Posted on 2004-10-09
2
909 Views
Last Modified: 2008-01-09
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
Comment
Question by:jameswalt
2 Comments
 
LVL 15

Expert Comment

by:efn
ID: 12269224
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
 

Accepted Solution

by:
Mamata_gd earned 50 total points
ID: 12269366
Also check if there is object with same name semname. BTW, what is 0644???
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now