多进程和多线程信能测试
  创建然后终止进程50000次
  创建进程代码
// fork.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#define NFORKS 50000
void do_nothing()
{
int i;
i= 0;
}
int main(int argc, char *argv[])
{
int pid, i, status;
for (i=0; i<NFORKS; i++) {
/*** error handling ***/
if ((pid = fork()) < 0 ) {
printf ("fork failed with error code= %d ", pid);
exit(0);
}
/*** this is the child of the fork ***/
else if (pid ==0) {
do_nothing();
exit(0);
}
/*** this is the parent of the fork ***/
else {
waitpid(pid, &status, 0);
}
}
exit(0);
}
  创建线程代码
  创建然后终止线程50000次
// pthread_create.c
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#define NTHREADS 50000
void *do_nothing(void *null)
{
int i;
i=0;
pthread_exit(NULL);
}
int main(int argc, char *argv[])
{
int rc, i;
pthread_t tid;
for (i=0; i<NTHREADS; i++) {
rc = pthread_create(&tid, NULL, do_nothing, NULL);
if (rc) {
printf("ERROR; return code from pthread_create() is %d ", rc);
exit(-1);
}
/* Wait for the thread */
rc = pthread_join(tid, NULL);
if (rc) {
printf("ERROR; return code from pthread_join() is %d ", rc);
exit(-1);
}
}
pthread_exit(NULL);
}