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 variable interfere with each other in threads?
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT ULTRIX
shmget
shmget(2) System Calls Manual shmget(2)Name
shmget - get shared memory segment
Syntax
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
int shmget (key, size, shmflg)
key_t key;
int size, shmflg;
Description
The system call returns the shared memory identifier associated with key.
A shared memory identifier and associated data structure and shared memory segment of size size bytes are created for key, if one of the
following is true:
The key is equal to IPC_PRIVATE. For further information, see
The key does not already have a shared memory identifier associated with it, and (shmflg & IPC_CREAT ) is true.
Upon creation, the data structure associated with the new shared memory identifier is initialized as follows:
The and are set equal to the effective user ID and effective group ID of the calling process.
The low-order nine bits of are set equal to the low-order nine bits of shmflg. The is set equal to the value of size.
The and are set equal to zero (0). The shm_ctime is set equal to the current time.
Return Values
Upon successful completion, a non-negative integer, namely, a shared memory identifier is returned. Otherwise, a value of -1 is returned
and errno is set to indicated the error.
Diagnostics
The system call fails if any of the following is true:
[EINVAL] The size is less than the system-imposed minimum or greater than the system-imposed maximum.
[EACCES] A shared memory identifier exists for key, but operations permission, as specified by the low-order nine bits of shmflg,
would not be granted. For further information, see
[EINVAL] A shared memory identifier exists for key, but the size of the segment associated with it is less than size and size is not
equal to zero.
[ENOENT] A shared memory identifier does not exist for key, and (shmflg & IPC_CREAT ) is false.
[ENOSPC] A shared memory identifier is to be created, but the system-imposed limit on the maximum number of allowed shared memory
identifiers would be exceeded.
[ENOMEM] A shared memory identifier and the associated shared memory segment are to be created, but the amount of available physical
memory is not sufficient to fill the request.
[EEXIST] A shared memory identifier exists for key, but ((shmflg & IPC_CREAT ) and (shmflg & IPC_EXCL )) is true.
See Alsoshmctl(2), shmop(2), ftok(3)shmget(2)