::: °­ÁÂ/¼Ò½º/¹®¼­ :::

°­ÁÂ/¼Ò½º/¹®¼­ ¼º°Ý¿¡ ¸ÂÁö ¾Ê´Â ±¤°í,ºñ¹æ,Áú¹®ÀÇ ±ÛÀº Áï½Ã »èÁ¦Çϸç
³»¿ëÀ» º¹»çÇÏ¿© »ç¿ëÇÒ °æ¿ì ¹Ýµå½Ã ÀÌ°÷(http://www.howto.pe.kr)À» Ãâó·Î ¸í½ÃÇÏ¿© ÁÖ¼¼¿ä


Category

  ±è¿µ´ë(2003-03-17 02:11:11, Hit : 6625, Vote : 1688
 [Thread] pthread_cond() function

/***************************************************
*--------------------------------------------------
*   Creat  : 2001. 04. 10  (programed by Cori-Young )
*   Site: http://www.byoneself.co.kr
*   Update :
*--------------------------------------------------
*   Compile : cc -o xxx xxx.c -lpthread -lrt
*--------------------------------------------------
* Machine hardware:   sun4u
* OS version:         5.7
* Processor type:     sparc
* Hardware:           SUNW,Ultra-60
***************************************************/


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

void* compute_thread(void*);

pthread_mutex_t my_sync;
pthread_cond_t rx;

int thread_done = FALSE;

main()
{
         pthread_t tid;
         pthread_attr_t attr;
        
         char hello[] {"Hello, "};
         char thread[] {"thread"};

         pthread_attr_init(&attr);
        pthread_mutex_init(&my_sync,NULL);
        pthread_cond_init(&rx,NULL);
        pthread_create(&tid, &attr, compute_thread, hello);
        
         /* wait until the thread does its work */
        pthread_mutex_lock(&my_sync);
        
        while (!thread_done)
                pthread_cond_wait(&rx,&my_sync);
        
         /* When we get here, the thread has been executed */
        printf(thread);
        printf("n");
        pthread_mutex_unlock(&my_sync);
        exit(0);
}

void* compute_thread(void* dummy)
{
   pthread_mutex_lock(&my_sync);
   printf(dummy);
   thread_done = TRUE;
          pthread_cond_signal(&rx);
          pthread_mutex_unlock(&my_sync);
          return;

}





62   [Unix/Linux] [¼Ò½º] top for SunOS 5.x (Solaris 2.x)  ±è¿µ´ë 2004/02/20 15448 1330
61   [Unix/Linux] [°­ÁÂ] ÀÎÅÚ ¼¾Æ®¸®³ë ¹«¼±·£ Ä«µå: ndiswrapper  ±è¿µ´ë 2004/06/27 12541 2189
60   [Unix/Linux] [POSIX IPC] mq_send() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 12399 1704
59   [Unix/Linux] [System V IPC] shmget() function - °øÀ¯¸Þ¸ð¸®  ±è¿µ´ë 2003/03/17 11191 1789
58   [Unix/Linux] [¼Ò½º] top for System V Release 4, Intel or Sparc CPU  ±è¿µ´ë 2004/02/20 11164 1288
57   [Unix/Linux] [Thread] pthread_cond_timedwait() function  ±è¿µ´ë 2003/03/17 11093 1875
56   [Unix/Linux] [Thread] pthread_setschedparam() function  ±è¿µ´ë 2003/03/17 10902 1868
55   [Unix/Linux] [System V IPC] shmctl() function - °øÀ¯¸Þ¸ð¸®  ±è¿µ´ë 2003/03/17 9881 1704
54   [Unix/Linux] [°­ÁÂ] Apache + MySQL + PHP4 + Zend Optimizer ¼³Ä¡  ±è¿µ´ë 2003/04/15 8666 1600
53   [Unix/Linux] [°­ÁÂ] À¥·Î±×ºÐ¼®À» À§ÇÑ Webalizer + GDlib + PNGlib + Zlib ¼³Ä¡  ±è¿µ´ë 2003/05/04 8520 1513
52   [Unix/Linux] [System V IPC] msgsnd() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 8336 1920
51   [Unix/Linux] [POSIX IPC] mq_receive() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 8256 1822
50   [Unix/Linux] [POSIX IPC] »ý»êÀÚ/¼ÒºñÀÚ - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 8117 5691
49   [Unix/Linux] [¼Ò½º] String Çؽ¬(hash) ÇÔ¼ö  ±è¿µ´ë 2003/07/29 8047 1589
48   [Unix/Linux] [Thread] pthread_cancel() function  ±è¿µ´ë 2003/03/17 8046 3802
47   [Unix/Linux] [Thread] »ý»êÀÚ/¼ÒºñÀÚ 2  ±è¿µ´ë 2003/03/17 8004 1533
46   [Unix/Linux] [Thread] pthread_attr_getschedparam() function  ±è¿µ´ë 2003/03/17 7013 8214
45   [Unix/Linux] [System V IPC] msgrcv() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 7011 1695
44   [Unix/Linux] [Thread] Àаí/¾²±â  ±è¿µ´ë 2003/03/17 6829 1529
43   [Unix/Linux] [System V IPC] semget() function - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 6682 1658

1 [2][3][4]
 

Copyright 1999-2024 Zeroboard / skin by zero