From: Christoph Rohland <cr@sap.com>
To: "Juan J. Quintela" <quintela@fi.udc.es>
Cc: linux-mm@kvack.org
Subject: Re: New Memory Test Suite v0.0.1
Date: 27 Apr 2000 19:57:45 +0200 [thread overview]
Message-ID: <qww3do71l5y.fsf@sap.com> (raw)
In-Reply-To: "Juan J. Quintela"'s message of "27 Apr 2000 01:31:39 +0200"
[-- Attachment #1: Type: text/plain, Size: 149 bytes --]
"Juan J. Quintela" <quintela@fi.udc.es> writes:
> Any comments/suggestions/code are welcome.
Here comes my shm test proggy.
Greetings
Christoph
[-- Attachment #2: ipctst.c --]
[-- Type: text/plain, Size: 1915 bytes --]
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
int main (int ac, char **av) {
int segs, size, proc, rmpr;
unsigned long long iter;
struct shmid_ds buf;
pid_t pid;
if (ac < 6) {
printf ("usage: shmtst segs size proc iter rm%%\n");
exit (1);
}
segs = atoi (av[1]);
size = atoi (av[2]);
proc = atoi (av[3]);
iter = atoi (av[4]);
rmpr = atoi (av[5]);
iter = 1 << iter;
printf ("using %d segs of size %d (%llu iterations)\n",
segs, size, iter);
while (-- proc) {
if ((pid = fork()) > 0) {
printf ("started process %d\n", (int) pid);
} else {
break;
}
}
srandom (getpid());
while (iter--) {
key_t key;
int seg, i, rm;
unsigned char c, *ptr;
volatile unsigned char *p;
key = random() % segs +1;
if ((seg = shmget (key, size, IPC_CREAT| 0600)) == -1) {
perror("shmget");
if (errno != EIDRM && errno != ENOSPC)
exit (1);
continue;
}
if (1) sched_yield();
if ((ptr = shmat (seg, 0, 0)) == (unsigned char *) -1) {
perror ("shmat");
continue;
}
if (random () % 100 < rmpr) {
if (random() % 1)
rm = 1;
else
rm = -1;
} else {
rm = 0;
}
if (rm < 0 &&
shmctl (seg, IPC_RMID, NULL) == -1)
perror("pre: shmctl IPC_RMID");
for (p = ptr; p < ptr + size; p += 4097)
*p = (unsigned char) (p - ptr);
for (p = ptr; p < ptr + size; p += 4097) {
c = *p;
if (c == (unsigned char)(p-ptr))
continue;
shmctl (seg, IPC_STAT, &buf);
printf ("n=%i, m = %i: %i != %i", (int) buf.shm_nattch,
(int)buf.shm_perm.mode,
(int)(unsigned char)(p-ptr), (int) c);
for (i = 0 ; i < 5; i++) {
printf (", %i", (int)*p);
sched_yield();
}
printf ("\n");
}
if (shmdt (ptr) != 0) {
perror("shmdt");
exit (1);
}
if (rm > 0 &&
shmctl (seg, IPC_RMID, NULL) == -1)
perror("post shmctl IPC_RMID");
}
}
prev parent reply other threads:[~2000-04-27 17:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-26 23:31 Juan J. Quintela
2000-04-27 17:57 ` Christoph Rohland [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=qww3do71l5y.fsf@sap.com \
--to=cr@sap.com \
--cc=linux-mm@kvack.org \
--cc=quintela@fi.udc.es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox