[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

502.0. "Global section communication" by CHAMBR::GUINEAU () Fri Jun 19 1987 11:48


Does anyone have an example of a process communicating with a (its) subprocess
via a global section (in C if possible)?


Basically I want to have a process spawn a subprocess that continuously
updates some values in a global section. The main process can read these
values and also write new values to another location in the section.

How can the subprocess best be notified when the main process writes
something to the section (global event flag?)?



T.RTitleUserPersonal
Name
DateLines
502.1VIDEO::LEICHTERJJerry LeichterSat Jun 20 1987 14:1728
I've got a whole bunch of code to do this, in C - but it's not easy to give
you any simple examples.  It's basically simple, however.

Telling one process that another one wrote to the common section can be done
in a variety of ways; which one is best really depends on exactly what you
are trying to do.  Event flags are fine in a 1 sender to 1 receiver configu-
ration; for multiple receivers, things break down - it becomes difficult to
clear the event flag.  Most of the communications I need to do is to one or
more processes that are known to be waiting for the result.  Process that
are waiting add their ID to a queue in shared memory and hibernate.  When
whatever they are waiting for happens, whoever caused it to happen scans the
queue doing WAKE's.  A bit in shared memory is also set to indicate that the
event really did happen.

When the receiver needs timely notification but isn't sleeping, you can use
blocking AST's.  (In fact, you can use the lock manager for all your synchro-
nization - I don't because it's a  much more heavy-weight - and expensive -
mechanism than I need.)

My code is in VIDEO::USER$5:[LEICHTERJ.JLINDA].  SECTIONS.C creates shared
global sections.  The basic synchronization primitives are in SYNC.MAR - sorry,
no C versions.  (It's not much code.)  There's other code, in C, that uses
the primitives - in TSPACE.C, function k_in(), near label do_hiber I think,
waits for notification from k_out(); the notification code is at the end of
k_out().

Good luck!
							-- Jerry
502.2CHAMBR::GUINEAUMon Jun 22 1987 13:0847



Thanks Jerry!

Basically, I'm writing some software to control programmable power supplies
and temperature chambers, which allows network links to (whatever) systems
that are exercising/diagnosing devices in the chambers.

I want to make the interface to the chamber and power supplies as flexible
as possible so anyone can write a simple "driver" (not device driver) routine
to talk to ANY make of chambers and power supplies. 

To avoid recompiling the control software when support for a new ch/ps 
is required, I decided upon a generic set of chamber and power supply
control functions (ex. set volt, set temp, etc..) which will be communicated
to to whatever driver is required via a global section. In this way the
user needs only to write a simple driver and then tell the software what it's
name is. The software then does a $CREPRC on the driver and opens communication
through the global section.

So there will be only 1 sender and 1 reciever in this case. The driver is
responsible for updating various "current setpoints" in the section. The
control software can then quickly obtain the current values. When the
need arises to change values (raise temp, change voltage etc) the software
writes to (dedicated areas in) the section. I wanted to get as quick a response
from the driver as possible.

I like the idea of a $WAKE, this could simply be another requirement of the
driver (- sleep till I say go). 


Whats a blocking AST?


I pulled your examples over to have a look

> SYNC.MAR - sorry, no C versions.

No problem, I've done *much* more macro than C. Just want to learn more C.



Thanks again,

John
502.3PPLRTLCLT::GILBERTeager like a childWed Jun 24 1987 00:465
    Version 5.0 of VMS includes RTL routines for parallel processing.
    These have nice interfaces for sharing memory and for synchronization.

    Further information is in the PPLRTL conference (press Select).
    A kit usable on V4.n systems is supposed to be available any day now.
502.4Queues in Global Section52451::NITSANDuvdevani, DEC IsraelWed Jun 24 1987 07:2810
If it helps, we used some inter-process queue system, based on a global-
-section, in one of our projects. It has features like:

 o  fast and efficient (no qio to mailboxes)
 o  regular queues and priority queues

Basically, it uses cyclic queues managed in memory (with head & tail & all
that), with common-event-flag notification and smart use of ASTs & $SETAST.

/Nitsan