Sponsored Content
Full Discussion: producer-consumer problem
Top Forums Programming producer-consumer problem Post 302270231 by joey on Saturday 20th of December 2008 08:09:18 AM
Old 12-20-2008
what if i use semget semop and not use pthread_mutex_lock..
shall it work?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Producer/Consumer

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... (3 Replies)
Discussion started by: poorni_uma
3 Replies

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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

10. Homework & Coursework Questions

Abnormal producer consumer problem driving me nuts

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: normally, i hate asking someone to do my homework for me but am getting desperate right now. i have a project... (1 Reply)
Discussion started by: alexantosh
1 Replies
SEMGET(2)						      BSD System Calls Manual							 SEMGET(2)

NAME
semget -- get set of semaphores LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/sem.h> int semget(key_t key, int nsems, int semflg); DESCRIPTION
The semget() system call returns the semaphore identifier associated with key. A new set containing nsems semaphores is created if either key is equal to IPC_PRIVATE, or key does not have a semaphore set associated with it and the IPC_CREAT bit is set in semflg. If both the IPC_CREAT bit and the IPC_EXCL bit are set in semflg, and key has a semaphore set associated with it already, the operation will fail. If a new set of semaphores is created, the data structure associated with it (the semid_ds structure, see semctl(2)) is initialized as fol- lows: o sem_perm.cuid and sem_perm.uid are set to the effective uid of the calling process. o sem_perm.gid and sem_perm.cgid are set to the effective gid of the calling process. o sem_perm.mode is set to the lower 9 bits of semflg. o sem_nsems is set to the value of nsems. o sem_ctime is set to the current time. o sem_otime is set to 0. RETURN VALUES
semget() returns a non-negative semaphore identifier if successful. Otherwise, -1 is returned and errno is set to reflect the error. ERRORS
[EACCES] The caller has no permission to access a semaphore set already associated with key. [EEXIST] Both IPC_CREAT and IPC_EXCL are set in semflg, and a semaphore set is already associated with key. [EINVAL] nsems is less than 0 or greater than the system limit for the number in a semaphore set. A semaphore set associated with key exists, but has fewer semaphores than the number specified in nsems. [ENOSPC] A new set of semaphores could not be created because the system limit for the number of semaphores or the number of sema- phore sets has been reached. [ENOENT] IPC_CREAT is not set in semflg and no semaphore set associated with key was found. SEE ALSO
ipcs(1), semctl(2), semop(2), ftok(3) STANDARDS
The semget system call conforms to X/Open System Interfaces and Headers Issue 5 (``XSH5''). HISTORY
Semaphores appeared in the first release of AT&T System V UNIX. BSD
May 13, 2004 BSD
All times are GMT -4. The time now is 01:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy