Subject: SHM test program: please run
To: None <port-amiga@netbsd.org>
From: Ignatios Souvatzis <ignatios@cs.uni-bonn.de>
List: port-amiga
Date: 06/01/1999 12:18:30
--M9NhX3UHpAaciwkO
Content-Type: text/plain; charset=us-ascii
Please run this program and tell me what happens.
(Extract the 3 files: shm1.c, shm2.c, Makefile; then "make test")
Regards,
Ignatios
--
* Progress (n.): The process through which Usenet has evolved from
smart people in front of dumb terminals to dumb people in front of
smart terminals. -- obs@burnout.demon.co.uk (obscurity)
--M9NhX3UHpAaciwkO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=Makefile
CC=gcc
COPTS=-O2
all: shm1 shm2
clean: ; rm shm1 shm2
test: all
./shm1
./shm2
--M9NhX3UHpAaciwkO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="shm1.c"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
int
main(int argc, char *argv[]) {
int myid;
char *buf;
void *p;
myid = shmget((key_t)0x4712, 80, IPC_CREAT| 0700);
if (myid == -1) {
perror("shmget");
exit(1);
}
printf("Returned %d\n", myid);
p = shmat(myid, 0, 0);
if (p == (void *)-1) {
perror("shmat");
exit(1);
}
printf("Returned 0x%08x\n", p);
strncpy((char *)p,
"The quick brown fox jumps over the lazy dogs' back", 80);
}
--M9NhX3UHpAaciwkO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="shm2.c"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
int
main(int argc, char *argv[]) {
int myid, rc;
void *p;
myid = shmget((key_t)0x4712, 80, 0700);
if (myid == -1) {
perror("shmget");
exit(1);
}
printf("Returned %d\n", myid);
p = shmat(myid, 0, 0);
printf("%-80s\n", p);
rc = shmctl(myid, IPC_RMID, 0);
if (rc == -1) {
perror("shmctl");
exit(1);
}
}
--M9NhX3UHpAaciwkO--