/* * numados: stress test the tasklist lock. * * Copyright (C) 1999, 2001, 2003 by Manfred Spraul. * All rights reserved except the rights granted by the GPL. * * Redistribution of this file is permitted under the terms of the GNU * General Public License (GPL) version 2 or later. * $Header: /pub/home/manfred/cvs-tree/getdents/getdents.cpp,v 1.1 2003/03/16 21:07:43 manfred Exp $ */ #include #include #include #include #include #include #include #include #include #include #define BUFSZ 4096 unsigned char entries[BUFSZ]; #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ type name(type1 arg1,type2 arg2,type3 arg3) \ { \ long __res; \ __asm__ volatile ("int $0x80" \ : "=a" (__res) \ : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \ "d" ((long)(arg3))); \ __syscall_return(type,__res); \ } _syscall3(int, getdents, uint, fd, struct dirent *, dirp, uint, count); static void poll_tasklist(void) { int fd, retval; for (;;) { fd = open("/proc",O_RDONLY); if (fd < 0) { printf("open failed, errno %d.\n", errno); exit(4); } lseek(fd, 1000000, SEEK_SET); retval = getdents(fd, (struct dirent *)entries, BUFSZ); close(fd); } } int main(int argc, char **argv) { int retval; int forks, readers; int i; printf("numados \n"); if (argc != 3) return 1; forks=atoi(argv[1]); readers=atoi(argv[2]); printf("Forks: %d.\n", forks); for (i=0;i