Solved

sem_open and sem_getvalue

Posted on 2004-10-09
2
907 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

746 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

12 Experts available now in Live!

Get 1:1 Help Now