Sponsored Content
Full Discussion: Inter Process Communication
Top Forums Programming Inter Process Communication Post 4946 by Neo on Saturday 4th of August 2001 07:03:55 PM
Old 08-04-2001
Semaphores are just flags that a program (programmer) uses to see if the flags are set or clear. By kernel rules, so to speak, the flags are guarenteed to be atomic.

When reading and writing shared memory, you must wrap your opens, reads and writes in each process to check the a semaphore to see if it is set or clear.

Semaphores can be used with lots of things, however they are often used as you ask, with shared memory access.
 

10 More Discussions You Might Find Interesting

1. Programming

signal in process communication

signal in process communication: I 'm a example in sun_unix that signal in process communication It's here down but I only have freebsd in my machine. how can i do the same in freebsd eg: #include <stdio.h> #include <signal.h> #include <unistd.h> int main( void ){ void... (2 Replies)
Discussion started by: a9711
2 Replies

2. HP-UX

Inter Process File Handling Problem

Hi All, i am running a oracle procedure which writes a file . The same file is picked up by another script which runs in a cron after every 5 minutes. Now the problem is that sometimes my script picks up a file while the procedure is still writing data in the file. is there is any way i... (4 Replies)
Discussion started by: saurabhjain
4 Replies

3. Programming

Problem with signals - 3 process communication

Hello, I would like to ask you for a little help with program I'm working on. I have problems with signals and synchronizing processes (I'm quite new to this part of programming). Process "parent" creates new child process "child1" and this process creates new child process "child2". The... (2 Replies)
Discussion started by: Nightwright
2 Replies

4. UNIX for Advanced & Expert Users

Inter-process communication:pipes,doors,etc.

Hi, I am thinking about writing a log daemon for a multi-processed ksh application (yes - I know that high-level language would be a better option). My question is as follows: If many processes (many scripts) will try writing to a single log file: print "message" > common.log Will it work or... (2 Replies)
Discussion started by: adderek
2 Replies

5. Programming

C program using IPC (inter process communication)

i want to write a C chat program that communicates over IPC(inter process communication), that could be run using 2 seperate terminal windows within the same computer. so that wat u type in one terminal window , should appear on the other and vice versa... could some one please help me with the... (2 Replies)
Discussion started by: localp
2 Replies

6. Programming

help with write-read locks inter-process

I need help!Many Thanks! Now,I try to manage the shared memory inter-process . Inevitably,I have to deal with the synchronous. I know the pthread_rwlock in posix,and I compile ,then run successfully in Red Hat Enterprise 4. I have a doubt about whether the Posix supports the system such as... (1 Reply)
Discussion started by: weizh
1 Replies

7. OS X (Apple)

Inter-shell communication

If I open two bash shells and telnet from Shell 2 to a remote server (on the Net), is there a way to direct input from Shell 1 to the telnet shell? The telnet shell is a limited environment with a specific command set. I want to direct commands from Shell 1 and, if possible, put 1-second... (2 Replies)
Discussion started by: xinUoG
2 Replies

8. Programming

logic understanding for inter client chat server

hello everyone, i am making chat server in linux using c. i have made programs in which group chat can take place between multiple clients but i am not able to understand how to make 2 particular clients chat with each other. please help!!! (1 Reply)
Discussion started by: sweetbella
1 Replies

9. Programming

Application with communication between process

Hello I would like to create an application with communication between processes, application tightly coupled, have you please an idea about an API or a tool that allows me to generate such application? Thank you so much (11 Replies)
Discussion started by: chercheur857
11 Replies

10. IP Networking

Implement inter vlan routing with Linux

Hello. I want to Communicate 2 VLAN with router like this solution: http://8pic.ir/images/83m0ouih8mmm9s1sfl56.jpg For this purpose I'm configuring 2 Linux system as a switch and connect 4 host to them. Then a router is added to scenario. The configuration of the switches is: On DUT1(Linux):... (1 Reply)
Discussion started by: zsn
1 Replies
SEMA(9) 						   BSD Kernel Developer's Manual						   SEMA(9)

NAME
sema, sema_init, sema_destroy, sema_post, sema_wait, sema_timedwait, sema_trywait, sema_value -- kernel counting semaphore SYNOPSIS
#include <sys/types.h> #include <sys/lock.h> #include <sys/sema.h> void sema_init(struct sema *sema, int value, const char *description); void sema_destroy(struct sema *sema); void sema_post(struct sema *sema); void sema_wait(struct sema *sema); int sema_timedwait(struct sema *sema, int timo); int sema_trywait(struct sema *sema); int sema_value(struct sema *sema); DESCRIPTION
Counting semaphores provide a mechanism for synchronizing access to a pool of resources. Unlike mutexes, semaphores do not have the concept of an owner, so they can also be useful in situations where one thread needs to acquire a resource, and another thread needs to release it. Each semaphore has an integer value associated with it. Posting (incrementing) always succeeds, but waiting (decrementing) can only success- fully complete if the resulting value of the semaphore is greater than or equal to zero. Semaphores should not be used where mutexes and condition variables will suffice. Semaphores are a more complex synchronization mechanism than mutexes and condition variables, and are not as efficient. Semaphores are created with sema_init(), where sema is a pointer to space for a struct sema, value is the initial value of the semaphore, and description is a pointer to a null-terminated character string that describes the semaphore. Semaphores are destroyed with sema_destroy(). A semaphore is posted (incremented) with sema_post(). A semaphore is waited on (decremented) with sema_wait(), sema_timedwait(), or sema_trywait(). The timo argument to sema_timedwait() specifies the minimum time in ticks to wait before returning with failure. sema_value() is used to read the current value of the semaphore. RETURN VALUES
The sema_value() function returns the current value of the semaphore. If decrementing the semaphore would result in its value being negative, sema_trywait() returns 0 to indicate failure. Otherwise, a non-zero value is returned to indicate success. The sema_timedwait() function returns 0 if waiting on the semaphore succeeded; otherwise a non-zero error code is returned. ERRORS
The sema_timedwait() function will fail if: [EWOULDBLOCK] Timeout expired. SEE ALSO
condvar(9), locking(9), mtx_pool(9), mutex(9), rwlock(9), sx(9) BSD
February 1, 2006 BSD
All times are GMT -4. The time now is 07:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy