2012年12月7日 星期五

pthread


#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>

void *test(void *param){
int *ptr = (int *)param;
printf("@@@ pthread 1\n");
*ptr = 60;
pthread_exit(0);
}

int main(void){
pthread_t tid;
pthread_attr_t attr;
int para=50;

pthread_attr_init(&attr);

pthread_create(&tid,&attr,test,&para);

pthread_join(tid,NULL); //wait

printf("@@@ main thread end =%d...\n",para);

return 0;
}

gcc pthread.c -lpthread -o test



g_ha_taskP = kthread_create(ha_thread, NULL, "ha"); 
schedule();    // sleep until wakeup
wake_up_process(g_ha_taskP);

沒有留言:

張貼留言