Solved

sem_open and sem_getvalue

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

810 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