473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SGI: Need Something like 1 Mutual Exclusion Semaphore for Multible Programs

Hello,

I have a assignment just thrown onto my desk.

What is the easiest way to solve it? Below is a brief
description of the task.

There are multible programs which use the same library routine
which is an interface to what I'll call a service program.

The problem is that only 1 request at a time can be serviced by
the service program.

My boss told me to just use somehting such as using shared
memory (via memmap) and set a flag in there to 1 when a program
wants service. The various programs are to wait in a loop until
that flag becomes 0. Once the flag becomes 0 then set it to 1 along
with setting other parameters to send to the service program.

But, woun't this lead to programs setting that flag to 1 at the
same time causing loss of service etc.

The way I see it is the flag described above is a critical
section and must be protected by a mutual exclusion semaphore.

I don't see anything wrong with using shared memory for sending
other parameters to the service routine.

O'kay what should I do?

Thank you,
Christopher Lusardi

P.S.: I'm sorry if I'm posting this to the wrong group. :-[

Jul 23 '05 #1
5 2194
cl********@aol.com wrote:
Hello,

I have a assignment just thrown onto my desk.

[snip OT stuff]

O'kay what should I do?
1) Don't cross-post.

2) Use a spell checker.

3) Post to the appropriate forum. There is nothing here
remotely connected to C++ language issues.
Thank you,
Christopher Lusardi

P.S.: I'm sorry if I'm posting this to the wrong group. :-[


So you should be - you obviously had a pretty good idea that
this was OT here.

--
Lionel B

Jul 23 '05 #2
I can't use the following sequence because the programs that use the
library routine
reside on different computers.

sem_open
sem_init
sem_wait
sem_post
sem_post
The only thing I have to find out is how how do I declare the semaphore

to be in
shared memory.
Thanks,
Chris Lusardi

Jul 23 '05 #3
cl********@aol.com wrote:

I have a assignment just thrown onto my desk.
.... snip ...
P.S.: I'm sorry if I'm posting this to the wrong group. :-[


You are, in at least two of the groups you used. You also
neglected to set follow-ups to whatever home group you are using.
F'ups set.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Jul 23 '05 #4
In article <11**********************@g49g2000cwa.googlegroups .com>,
cl********@aol.com wrote:

: I have a assignment just thrown onto my desk.
:
: What is the easiest way to solve it? Below is a brief
: description of the task.
:
: There are multible programs which use the same library routine
: which is an interface to what I'll call a service program.
:
: The problem is that only 1 request at a time can be serviced by
: the service program.

There's a few options. You can, in order of decreasing preference:

* Fix your service program to queue requests
* Add an intermediary service program that queues requests to the service program
* Use some distributed API for locking (since you mention they're on different
machines), like maybe MPI, PVM, or something like RPC
* Use a reject-and-retry collision system

You could also possibly parallelize your service program so that it can serve
more than one request at a time, or make it transactional if it's not quite
parallelizable. It all depends on what your service program actually does.
Cheers - Tony 'Nicoya' Mantler :)

--
Tony 'Nicoya' Mantler -- Master of Code-fu -- ni****@ubb.ca
-- http://nicoya.feline.pp.se/ -- http://www.ubb.ca/ --
Jul 23 '05 #5
cl********@aol.com wrote:

I can't use the following sequence because the programs that use
the library routine reside on different computers.

sem_open
sem_init
sem_wait
sem_post
sem_post

The only thing I have to find out is how how do I declare the
semaphore to be in shared memory.


This has nothing to do with at least three of the groups to which
you cross-posted without troubling to find out what they were
about. F'ups set.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: clusardi2k | last post by:
Hello, I am looking for instructions that do what a mutual exclusive semaphore does but with some specifiable timeout for SGI and Red Hat Linux. (I.E.: A Semaphore with a count of 1 but with a...
4
by: clusardi2k | last post by:
Hello, I have a assignment just thrown onto my desk. What is the easiest way to solve it? Below is a brief description of the task. There are multible programs which use the same library...
4
by: Leonardo Hyppolito | last post by:
Hello, I am trying to write a multithread program that simulates producers and consumers. My program can have many producers and many consumers (each in a separate thread). It has a storage...
5
by: marvind | last post by:
I tried using a Semaphore class (have included the full listing reproduced from article Figure 1 at the end of this email) in .NET 1.1. It works fine most of the time, however, I see the following...
78
by: wkehowski | last post by:
The python code below generates a cartesian product subject to any logical combination of wildcard exclusions. For example, suppose I want to generate a cartesian product S^n, n>=3, of that...
10
by: preethamkumark | last post by:
- The program first creates a shared memory buffer containing an array of 20 integers. - Each slot of the buffer can have either 0 or 1, where 0 represents an empty slot, and 1 represents an...
1
by: cranfic | last post by:
Please help... To make it simple, I have a simple test C program which calls my semphore library functions only. (It doesn't call any db2 function at all). And the following is the test...
3
by: misu101 | last post by:
Hi, I have an application that defines a hash_set as: typedef hash_set<const char*, hash<const char*>, chunker_eqstr> StringSet; This code compiles OK with VS6 and SGI STL library. It is...
0
by: Samuel R. Neff | last post by:
I'm having trouble creating a Semaphore with read-access rights for everyone. Originally I was trying to use this code: semaphore = new Semaphore(maxLocks, maxLocks, "RwLock#" + name); but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.