Producer/Consumer


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Producer/Consumer
# 1  
Old 07-07-2005
iowait function call

Hi all,
I have an Producer/Consumer program in C(using shared memory and semaphores).It is working fine with sleep calls after every read/write operation.Each one is a independent program.Now if i remove the sleep calls in consumer,it goes on waiting in the loop till the producer puts some valid data.Instead of doing this i was asked to call iowait() I am not aware how to use this function.Can anyone suggest some link abt this call and how to use it in the code.

Thanx in advance
Poorni
# 2  
Old 07-08-2005
Producer/Consumer

hi
i have a producer consumer programs running with sleep() command after every successful read/write.Now if the sleep command in the consumer is removed then the consumer is looping continuosly for the producer to produce.Instead shall v make it wait till the producer writes into shared memory so that consumer can read????wait() cant be used as there is no parent- child relationship exists between these programs ..so is there any other way?????

thanx in advance
Poorni
# 3  
Old 07-08-2005
poorni_uma,

Please dont bump-up/repost questions. Thats against the forum rules.

Thanks,
Vino
# 4  
Old 07-08-2005
Read "man semop" and pay attention to the comments about IPC_NOWAIT.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Abnormal producer consumer problem driving me nuts

normally, i hate asking someone to do my homework for me but am getting desperate right now. i have a project about consumer producer problem. the deadline is tonight at 23:55. but i havent gotten it working yet. i just COULDNT get it to work right yet. the problem is as follows: the C - program... (0 Replies)
Discussion started by: alexantosh
0 Replies

2. Homework & Coursework Questions

producer consumer semaphore

Control two exclusively shared resources(semaphore). The two resources are two files. The producer will write even numbers to one file, and odd numbers to another one. The consumer respectively reads from each file until it gets 5 even numbers and 5 odd numbers. Can any one help me with the... (1 Reply)
Discussion started by: gokult
1 Replies

3. UNIX for Dummies Questions & Answers

producer consumer

Control two exclusively shared resources. The two resources are two files. The producer will write even numbers to one file, and odd numbers to another one. The consumer respectively reads from each file until it gets 5 even numbers and 5 odd numbers. Can any one help me with the code. ... (3 Replies)
Discussion started by: gokult
3 Replies

4. Programming

producer consumer semaphore

Control two exclusively shared resources(semaphore). The two resources are two files. The producer will write even numbers to one file, and odd numbers to another one. The consumer respectively reads from each file until it gets 5 even numbers and 5 odd numbers. Can any one help me with the... (0 Replies)
Discussion started by: gokult
0 Replies

5. UNIX for Advanced & Expert Users

producer consumer

Control two exclusively shared resources(semaphore). The two resources are two files. The producer will write even numbers to one file, and odd numbers to another one. The consumer respectively reads from each file until it gets 5 even numbers and 5 odd numbers. Can any one help me with the... (0 Replies)
Discussion started by: gokult
0 Replies

6. Shell Programming and Scripting

producer consumer

Control two exclusively shared resources. The two resources are two files. The producer will write even numbers to one file, and odd numbers to another one. The consumer respectively reads from each file until it gets 5 even numbers and 5 odd numbers. Can any one help me with the code. ... (1 Reply)
Discussion started by: gokult
1 Replies

7. Programming

producer consumer

Control two exclusively shared resources. The two resources are two files. The producer will write even numbers to one file, and odd numbers to another one. The consumer respectively reads from each file until it gets 5 even numbers and 5 odd numbers. Can any one help me with the code. ... (0 Replies)
Discussion started by: gokult
0 Replies

8. UNIX for Dummies Questions & Answers

Slow Producer - Fast consumer

I would like to loop through a set of directories, performing operation(s) on each one. The basic script** is dirs=`find . -name .svn -print` for f in $dirs; do echo "Processing $f directory .." done Fine and dandy, but here is the problem: the find expression must complete... (7 Replies)
Discussion started by: jakeo25
7 Replies

9. UNIX for Dummies Questions & Answers

Slow Producer - Fast consumer

I would like to loop through a set of directories, performing operation(s) on each one. The basic script** is dirs=`find . -name .svn -print` for f in $dirs; do echo "Processing $f directory .." done Fine and dandy, but here is the problem: the find expression must complete... (2 Replies)
Discussion started by: jakeo25
2 Replies

10. Programming

producer-consumer problem

The intention of the program. Create N threads with 2 shared memories. One shared memory to write, one shared memory to recieve. Consumer creates 2 shared memory to share with producer. I need H threads for the producer as well(somebody help on it..) Also another question, would segment_id... (2 Replies)
Discussion started by: joey
2 Replies
Login or Register to Ask a Question