Hi friends,
I have written this small program using the concept of semaphores. I am a bit confused, hope u can help me with it.
The idea is that
1. Two threads are created
2. First will be displaying 0(zero) on the screen
3. Second will be displaing 1(one) on the screen
4. This process will go on upto three times for each thread, it would look like
But the program that i have written prints like this
0
0
0
1
1
1
I don't really know what I am missing here, could you pin point it to me, I think my concept of semaphores is corrct.
You can have a look at my code
But the same program works when I put a sleep(1) in the middle like this
But I want to achieve what I want to achieve by using only semaphores, no sleep function,
hallo!
if there are many processes running and I initialize the semaphore like this:
my_sem = sem_open(SEM_NAME, O_CREAT | O_RDWR,
S_IRUSR | S_IWUSR, 10);
(the last argument is 10)
and then i use
sem_wait(my_sem);
sleep(5);
sem_post;
Will 10 processes be able to access the... (1 Reply)
Hello All,
I have a problem in counting number of process getting run with my current script name..
Here it is
ps -ef | grep $0 | grep -v grep
This display just one line with the PID, PPID and other details when i print it in the script.
But when I want to count the numbers in my... (11 Replies)
Hi friends,
I am using semaphores in my program, but when I compile the program, it gives the following error
$ gcc sem.c -o sem -lpthread
Undefined first referenced
symbol in file
sem_init ... (1 Reply)
Hell Unix.com Community:
I am working on a personal project using yad v0.12.4 (zenity fork) and have hit a wall on how to show a progress bar while my function is processing.
I have been all over the ABS Guide, googled 21 Linux-specific sites that I revere. I even asked on the yad-common... (4 Replies)
Hello, I hope all is well.
Two issues that I am grappling with.
One: Is this a true statement: (AIX, LDAP configured), even if authentication is configured with LDAP, the system would still need to be authenticated against local (/etc/passwd); incase of network failure?
Two: I can log... (0 Replies)
I have printer old about 5 year , but I can not determine which driver to use
output of
ls -al /usr/share/lib/terminfo/h
-rw-r--r-- 1 root bin 961 Jan 22 2005 h1000
-rw-r--r-- 1 root bin 1002 Jan 22 2005 h1420
-rw-r--r-- 1 root bin 1009... (2 Replies)
Hi,
I was trying to learn forking in C in UNIX. Somehow i still haven't been able to get the concept well. I mean, i do understand that fork creates an exact replica of the parent (other than the fact that parent gets the process id of the child and child gets 0 when fork is called). This is the... (2 Replies)
Good day, everyone!
Could anybody explain me the following situation.
If I'm running similar script:
Var="anna.kurnikova"
Var2="Anna Kurn"
echo $Var | tr -t "$Var" "$Var2"
Why the output is :
anna KurniKova
instead of Anna Kurnikova?
:confused:
Thank you in advance for any... (2 Replies)