???????????????????????????
???????????? ???????[ 2015/5/11 10:38:23 ] ???????????????
?????????????????????
??????????????????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);
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11