IPC-Questions (Sun SPARC)

IPC-Questions (Sun SPARC)

Post by Grether Bernd (sores » Fri, 14 Feb 1992 03:03:31



System: Sun SPARC

We need to transfer data from one program (a simulation) to another
(a graphic program). Up to now, we used a simple file to do that.
Of course we wanted to speed up things a little bit, so we decided
to use shared memory.
To test this, we wrote 2 little programs, one for writing, one for reading.
The procedure to read the contents could be (writing looks similar):

void
read_shm(shmname)

int     shmname;

{
  double        *start,*tmp,m1,m2;
  char          *shmat();
  int           n;

  tmp = start = (double *)shmat(shmname,0,1);   /* make shm accessable */

  n = (int)(*tmp++);   /* # of value pairs */

  for ( ; n > 0; n--)
  {
    m1 = *tmp++;   /* just reading dummies */
    m2 = *tmp++;
  }

  shmdt ((char*)start);

Quote:}

This works fine (and fast).

BUT:
In a Sun document named "Porting Software to SPARC Systems"
(from the "Programmer's Language Guides"), chapter 2, you
can read the following :

---
   On SPARC machines, all quantities must be aligned on
   boundaries corresponding to their sizes: bytes on byte
   boundaries, (16-bit) halfwords on halfword boundaries,

   ...[deleted]...

   There are several C language constructs, however, that
   may lead to a bus error during execution:

   - Casting a pointer to a char or unsigned char into
     a pointer to a larger quantity, such as ...[deleted]...
     double,

   ...[deleted]...
---

shmat() returns a char *. Is there any way to make sure,
that it points to a suitable boundary for a double?

Another question:
Is it a good idea to control the read/write access via
IPC-Queues (the 'writer' waits until the 'reader' says ok)?
Are there any examples for such a communication?

Thanks in advance,
Bernd


Universitaet Stuttgart
Institut fuer Chemische Verfahrenstechnik
Boeblinger Str. 72
D-7000 Stuttgart 1

 
 
 

IPC-Questions (Sun SPARC)

Post by Michael Dahm » Tue, 18 Feb 1992 16:58:36


Quote:> [program using shared memory]
> tmp = start = (double *)shmat(shmname,0,1);   /* make shm accessable */
> ...
> shmat() returns a char *. Is there any way to make sure,
> that it points to a suitable boundary for a double?

A suitable boundary for a double for a double is any multiple of
sizeof(double) == 8. You can test that after calling shmat(). If the
returned value should not be suitable, detach the shared memory (shmdt())
set 'start' to the next double boundary, and invoce shmat() passing
'start' as second argument. That asks shmat() to allocate at the address
you have passed.

--
Michael Dahmen                                  Tel. +49 89 926 99113

Arabellastr 17, 8000 Munich 81. Germany         UUCP: ...unido!ecrc!dahmen

 
 
 

1. Sun Sparc IPC and SunOS 4.1.1 - Questions

I am helping out a friend in setting up a Gerber Photoplotter (something to
print electronic PCB files onto film for manufacturing), of which the
controlling device is the aforementioned Sun Spark IPC running SunOS 4.1.1.
I am pretty familiar with Sparc 5's and Solaris 2.1 and 2.4.

Is there a place on the Net (other than here of course) where I can get
some good basic information on the differences. Also can anyone recommend a
book to cover System Admin, and maybe hardware? Any ideas greatly
appreciated, I'll post extra questions when I run up against the problems
;-).

Ta

Mark

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark Templeton - Engineering IT Co-ordinator
Swichtec Power Systems Limited,   | Phone: (++64) 3 343-3314
39 Princess St, PO Box 11-188,    | Fax:   (++64) 3 348-8871

Visit us at http://www.swichtec.co.nz
++++++++++++++++++++++++++++++++----------------------------------

2. ps/2 mouse just won't work

3. ref sun sparc ipc

4. Drawing a line

5. Help -- Pcomm on Sun Sparc IPC

6. truss?

7. Help Settin up Redhat on A sun sparc ipc

8. Apache Redirecting

9. Sun PCMCIA Interface/SBUS card on SPARC IPC Station

10. Redhat 5.2 on Sparc IPC Ramdisk question

11. How to put X11R6.4 in Sun Solaris 2.5.1 (running on Sun Ultra Sparc)

12. What NICs work on Sun Sparc systems other than those from Sun?

13. Sun Sparc Ultra 10 and Sony / Sun GDM-20D10