2 * $Id: ORTEThreadUtils.c,v 0.0.0.1 2003/08/21
4 * DEBUG: section 25 Thread utility
6 * -------------------------------------------------------------------
8 * Open Real-Time Ethernet
10 * Copyright (C) 2001-2006
11 * Department of Control Engineering FEE CTU Prague, Czech Republic
12 * http://dce.felk.cvut.cz
13 * http://www.ocera.org
15 * Author: Petr Smolik petr.smolik@wo.cz
17 * Project Responsible: Zdenek Hanzalek
18 * --------------------------------------------------------------------
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
34 /*****************************************************************************/
36 ORTEDomainWakeUpReceivingThread(ORTEDomain *d,sock_t *sock,uint16_t port) {
37 struct sockaddr_in des;
38 char sIPAddress[MAX_STRING_IPADDRESS_LENGTH];
41 des.sin_family = AF_INET;
42 des.sin_port = htons(port); //to receiving port
43 if (d->domainProp.IFCount) {
44 for(i=0;i<d->domainProp.IFCount;i++) {
45 des.sin_addr.s_addr=htonl(d->domainProp.IFProp[i].ipAddress);
46 sock_sendto(sock,&i,1,&des,sizeof(des));
47 debug(25,2) ("Sent wake up signal to: %s.%d\n",
48 IPAddressToString(ntohl(des.sin_addr.s_addr),sIPAddress),
52 des.sin_addr.s_addr = inet_addr("127.0.0.1"); //local IPAddress
53 sock_sendto(sock,&i,1,&des,sizeof(des));
54 debug(25,2) ("Sent wake up signal to: %s.%d\n",
55 IPAddressToString(ntohl(des.sin_addr.s_addr),sIPAddress),
60 /*****************************************************************************/
62 ORTEDomainWakeUpSendingThread(ObjectEntry *objectEntry) {
63 debug(25,10) ("WakeUpSendingThread : start\n");
64 if (objectEntry->htimNeedWakeUp) {
65 pthread_mutex_lock(&objectEntry->htimSendMutex);
66 if (objectEntry->htimSendCondValue==0) {
67 debug(25,8) ("WakeUpSendingThread : send wakeup signal\n");
68 pthread_cond_signal(&objectEntry->htimSendCond);
69 objectEntry->htimSendCondValue=1;
71 pthread_mutex_unlock(&objectEntry->htimSendMutex);