[comp.unix.microport] shared memory??

john@bby-bc.UUCP (john) (03/18/88)

I'm trying to use shared memory to access a frame buffer and it
doesn't seem to work. I am running 2.2L.  I put the appropriate
shmcreate lines in /etc/rc.d/shm.rc but when my program runs
nothing seems to happen (I check for error returns and from
shmat and shmget but no error indication is given).  to check it out
I tried the tiny programbelow to try and write some high intensity
"A"'s to the herc. mono adapter.  The program runs in a couple of seconds
but nothing changes on the screens.  The only thing I have noticed is
that in  system5.nm  shmat() is listed as an int rather than a char *

Any hints/suggestions are welcome; thanks!
john

 ...!ubc-vision!fornax!bby-bc!john


program below compiled by  cc -Ml prog.c

main (argc,argv)
int argc;
char **argv;
{
extern char *shmat();
int shmid=shmget(0xb0000,32768,0);
char *shmaddr = shmat(shmid,(char *)0);

unsigned int i;
for (i=0; i<32000; i++) {*shmaddr++ = 65; *shmaddr++ = 15;};
}

dave@sdeggo.UUCP (David L. Smith) (03/19/88)

In article <259@bby-bc.UUCP>, john@bby-bc.UUCP (john) writes:
> I'm trying to use shared memory to access a frame buffer and it
> doesn't seem to work. I am running 2.2L.  I put the appropriate
> shmcreate lines in /etc/rc.d/shm.rc but when my program runs
> nothing seems to happen (I check for error returns and from
> shmat and shmget but no error indication is given).  to check it out
> I tried the tiny programbelow to try and write some high intensity
> "A"'s to the herc. mono adapter.  The program runs in a couple of seconds
> but nothing changes on the screens.  The only thing I have noticed is
> that in  system5.nm  shmat() is listed as an int rather than a char *

Well, your program is correct, I compiled and ran it on 'eggo without any
problems (well, it gives a core dump at the end, but that's not your problem
just yet).

There's two things to check for:  On older version of 2.2, the shmcreate
program did not attach the segments properly.  You can check to see if
the segments exist with the ipcs program.  I think the problem showed up
with the segments being "r--r--r--" protected.  Maybe you can talk Microport
into giving you a version that works.  You may also want to make sure
that you are running the "large" kernel, since the one that is installed
by the installation procedure does not have any of the shared memory
routines.


-- 
David L. Smith
{sdcsvax!jack,ihnp4!jack, hp-sdd!crash, pyramid, uport}!sdeggo!dave
sdeggo!dave@amos.ling.edu 
Sinners can repent, but stupid is forever.

chapman@fornax.UUCP (John Chapman) (03/22/88)

In article <183@sdeggo.UUCP>, dave@sdeggo.UUCP (David L. Smith) writes:
> In article <259@bby-bc.UUCP>, john@bby-bc.UUCP (john) writes:
> > I'm trying to use shared memory to access a frame buffer and it
> > doesn't seem to work. I am running 2.2L.  I put the appropriate
.
.
.
> > "A"'s to the herc. mono adapter.  The program runs in a couple of seconds
> > but nothing changes on the screens.  The only thing I have noticed is
> > that in  system5.nm  shmat() is listed as an int rather than a char *
> 
> Well, your program is correct, I compiled and ran it on 'eggo without any
> problems (well, it gives a core dump at the end, but that's not your problem
> just yet).

Hmmmm, I don't have around anymore but I don't remember it core dumping....
 
> There's two things to check for:  On older version of 2.2, the shmcreate
> program did not attach the segments properly.  You can check to see if

This was my problem - Harold Walters (walters@ce.okstate.edu) sent me
some routines he had for accessing the ega in which he mentioned a patch
I tracked down the patch to /etc/shmcreate, applied it, and now everything
works like a charm.  For large chunks of memory (being moved to/from the
targa frame buffer) it was actually slower than using /dev/mem. I looked at the
code produced by cc for
	for (; n>0 ; n-- ) *dst++ = *src++;
and it was pretty bad even using cc -O.  I replaced the code by a
	mov n,%cx
	rep
	smov

and now everthing is much faster.  In the 2.2 man page it says /etc/shmcreate
is only a temporary solution for graphics and it can be expected to go
away - don't get rid of it Microport!! If you have something better for
graphics that is great - but leave shmcreate around, it's extremely useful
for doing oddball things in a reasonably efficient way.

john
 .....!ubc-vision!fornax!bby-bc!john