[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Multitrådet programmering



On Mon, May 01, 2000 at 03:49:00PM +0200, Jesper Monsted wrote:
> > Det er til en applikation der skal lave dataopsamling og styring af 6
> > serielle porte og sortering af data samt kommunikation til andre processer
> > der bruger disse data og styrer de serielle enheder.
> 
> Den nemmeste måde at lave tråde i linux er noget i denne retning:
> 
> if (fork())
>   {
>   /* parent */
>   gør noget;
>   }
> else
>   {
>   /* child */
>   gør noget andet;
>   return(0);
>   }
> 

Tja, fast det är ju inte en tråd. Där forkar du och får två processer:->

Ska du använda trådar så gör något liknande:
#include <pthread.h>

void *thread_proccess(void *d)
{
  //ny tråd
}


och för att starta den:

pthread_t data_thread;
pthread_create(&data_thread, NULL, thread_proccess, (void *) indata);


Dock är forkning ej att förkasta, det beror på hur mycket de olika
programsnuttarna behöver kommunicera med varandra och på vilket vis.

-- 
              Calvin: "Sometimes I think the surest
  -----                sign that intelligent life
  Bjorn                exists elsewhere in the
  -----                universe is that none of it
                       has ever tried to contact us"


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *