i've found the problem...
the right line of semop functions is:
semop(sem_id,operations,3)
because the last argument nsops is the number of sembuf structures in the array!
i.e.
Type: Posts; User: np2k
i've found the problem...
the right line of semop functions is:
semop(sem_id,operations,3)
because the last argument nsops is the number of sembuf structures in the array!
i.e.
MK27...you were in right...
it's my fault. the problem is another!!!!
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
no...i'm not in luck...
when i program the software with semaphore i don't have the behavior described in the second man pages...
the behavior of the semaphore. more precisely, of
semop function...
if i write:
man semop
i have this man:
SEMOP(2) Linux Programmer’s Manual SEMOP(2)
Hi all.
I want compile my program that uses semaphore for processes with the posix standard...but if I compile my program with:
gcc -o myprogram myprogram.c
I don't have the behavior of the...
Hi all.
I want get the length of a stdin. i.e
cat test.txt | myprogram
the program myprogram reads the test.txt and returns the length of the file test.txt
I've this code and a client that send data on the FIFO.
I start the client and the daemon below works perfectly. But when the client stop beacause of while cycle we go to "read function" and now...
yes, it's an elegant solution
for example, if you want the output of ls command you can use the following code.
but...first of all: this is a dirty solution: if your program must does other things, you will fork the process and...
as soon as i have a bit of time i write you the solution for get the output of system
I've understand only the first part of your message:
you can use a pipe&dup2 function to redirect the output of system() to the read-end of the pipe...If this does not say anything, let me know...
yes but I need the sem value for debugging my software
@tabstop: I know what an int* is...the strange -for me- is that I'm so lucky to get no error using arg.array without any allocation
seg fault
:S it seems very strange...
ok, but...there is the question 2...without malloc the things work....
1. I don't understand....why should be my work allocating the space for argument.array? It should be responsibility of the semctl function allocate this space...
2. and why the code I post works...
first of all i must set arg.array if i use SETALL...with GETALL cmd i want the information into senum argument...
then -reapet- I can retrieve the current value of the sem with these lines:
...
yes...and then?
I use semun array...have a look to my code
but wait wait....
unsigned short int get_semvalue(int sem_id) {
union semun argument;
semctl(sem_id,0,GETALL,argument);
return argument.array[0];
}
i response to myself.....
i don't init the sem_id value, just call the semget loosing the return value. so:
sem_id=semget(IPC_PRIVATE,1,IPC_CREAT|IPC_EXCL|S_IRUSR|S_IWUSR);
damn me!
Hi all. I'm using semaphore for processes.
Here a simple code:
...
//include declarations
...
union semun {
int val;
thanks...
sorry but I have not explained well, i'm italian and my english is not good. all of your speech was clear, from long time...I said something else, but now it's no important because I...
damn it! I had missed a "silly" detail...
but, wait...what a dirty thing! in this way, in thread_function routine I get the value of the args pointer's address which coincides with the value of i...
yes, salem. thanks for your links...but i've studied the threads and the program that i've post has a strange behavior: i don't have understand why.
ok, let me understand please
i don't understand...and, anyway, what could be a solution to this problem?