]> rtime.felk.cvut.cz Git - orte.git/blob - orte/liborte/ORTEThreadUtils.c
235fa502b9e755c13d186eaa89d017051a3e34c4
[orte.git] / orte / liborte / ORTEThreadUtils.c
1 /*
2  *  $Id: ORTEThreadUtils.c,v 0.0.0.1    2003/08/21 
3  *
4  *  DEBUG:  section 25                   Thread utility
5  *  AUTHOR: Petr Smolik                 petr.smolik@wo.cz
6  *
7  *  ORTE - OCERA Real-Time Ethernet     http://www.ocera.org/
8  *  --------------------------------------------------------------------
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *  
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *  
20  */ 
21
22 #include "orte_all.h"
23
24 /*****************************************************************************/
25 void
26 ORTEDomainWakeUpReceivingThread(ORTEDomain *d,sock_t *sock,uint16_t port) {
27   struct sockaddr_in    des;
28   char                  sIPAddress[MAX_STRING_IPADDRESS_LENGTH];
29   int                   i;
30
31   des.sin_family = AF_INET;
32   des.sin_port = htons(port);             //to receiving port
33   if (d->domainProp.IFCount) {
34     for(i=0;i<d->domainProp.IFCount;i++) {
35       des.sin_addr.s_addr=htonl(d->domainProp.IFProp[i].ipAddress);
36       sock_sendto(sock,&i,1,&des,sizeof(des));
37       debug(25,2) ("Sent wake up signal to: %s.%d\n",
38                     IPAddressToString(ntohl(des.sin_addr.s_addr),sIPAddress),
39       port);
40     }
41   } else {
42     des.sin_addr.s_addr = inet_addr("127.0.0.1"); //local IPAddress
43     sock_sendto(sock,&i,1,&des,sizeof(des));
44     debug(25,2) ("Sent wake up signal to: %s.%d\n",
45                   IPAddressToString(ntohl(des.sin_addr.s_addr),sIPAddress),
46                   port);
47   }
48 }
49
50 /*****************************************************************************/
51 void
52 ORTEDomainWakeUpSendingThread(ObjectEntry *objectEntry) {
53   debug(25,10) ("WakeUpSendingThread : start\n");
54   if (objectEntry->htimNeedWakeUp) {
55     pthread_mutex_lock(&objectEntry->htimSendMutex);
56     if (objectEntry->htimSendCondValue==0) {
57       debug(25,8) ("WakeUpSendingThread : send wakeup signal\n");
58       pthread_cond_signal(&objectEntry->htimSendCond);
59       objectEntry->htimSendCondValue=1;
60     }
61     pthread_mutex_unlock(&objectEntry->htimSendMutex);
62   }
63 }
64
65
66