2008-10-01 06:32:16 problem with IPC semaphores
Filip Van Rillaer (BELGIUM)
Message: 62975
Hello,
When pending (decrementing) a semaphore (with IPC_NOWAIT NOT set), the program exits instead of going to sleep (pending). When compiling and running the program on a Debian machine, it works as expected.
My testprogram takes 1 argument : a filename
e.g. ./tlwait /tmp/hello.txt
The program
1) creates the semaphore
2) initializes the semaphore to 1 (so it is available)
3) pending for the first time on the semaphore works fine
4) pending again for the semaphore should block .... but on uclinux blackfin the program exits.
PS. when using IPC_NOWAIT, the program works as expected, but that is not the behaviour I want to implement.
Please verify my program and comment.
attachment: the testprogram
URL: svn://firewall-sources.blackfin.uclinux.org:80/svn/linux-kernel/trunk
Repository Root: svn://firewall-sources.blackfin.uclinux.org:80/svn/linux-kernel
Repository UUID: 526b6c2d-f592-4532-a319-5dd88ccb003d
Revision: 5246
Best regards,
Filip
tlwait.c
TranslateQuoteReplyEditDelete
2008-10-01 10:18:12 Re: problem with IPC semaphores
Mike Frysinger (UNITED STATES)
Message: 62982
works fine for me
root:/> /a.out moo
member value 1
OK after 1st semop moo
<hangs here>
with strace:
root:/> strace /a.out /asdfasdf
execve(NULL, [0x3a46f74], [/* 0 vars */] <unfinished ...>
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B57600 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B57600 opost isig icanon echo ...}) = 0
rt_sigaction(SIGINT, {0x398813c, [INT], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGTERM, {0x398813c, [TERM], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGHUP, {0x398813c, [HUP], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGALRM, {0x398813c, [ALRM], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
unlink("/asdfasdf") = -1 ENOENT (No such file or directory)
open("/asdfasdf", O_RDONLY|O_CREAT, 0) = 3
stat("/asdfasdf", {st_mode=S_IFREG, st_size=0, ...}) = 0
semget(0x73010a36, 1, IPC_CREAT|IPC_EXCL|0666) = 163840
semctl(163840, 0, IPC_64|SETVAL, 0x1) = 0
semctl(163840, 0, IPC_64|GETVAL, 0) = 1
write(1, "member value 1\n"..., 15member value 1
) = 15
semop(163840, 0xa0a0a0a, 60354312) = 0
write(1, "OK after 1st semop /asdfasdf\n"..., 29OK after 1st semop /asdfasdf
) = 29
semop(163840, 0x398bb41, 60354312
QuoteReplyEditDelete
2008-10-01 10:54:56 Re: problem with IPC semaphores
Filip Van Rillaer (BELGIUM)
Message: 62991
Hello Mike,
Sorry for consuming your time, I made a mistake. On blackfin I started the tlwait program from within a script. I copied the line from somewhere else ... and that line ended with & so in fact the tlwait program moved to the background.
On my Debian machine I started the program by typing the command and did not make that mistake.
Again, sorry for disturbing you.
Filip.
TranslateQuoteReplyEditDelete
2008-10-01 11:00:15 Re: problem with IPC semaphores
Mike Frysinger (UNITED STATES)
Message: 62993
np, glad you found the problem