Changes between Version 4 and Version 5 of Old/NodeHandler/Broadcast


Ignore:
Timestamp:
Apr 10, 2006, 9:35:00 PM (18 years ago)
Author:
sswami
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Old/NodeHandler/Broadcast

    v4 v5  
    106106
    107107The NodeHandler on startup will open the required pipes and then fork the Communication Server
    108 process. The Communication Server is a 2-threaded process. Following is the algorithm for this
    109 process functionality:
     108process. The Communication Server is a 2-threaded process. Following is the pseudo-code for
     109this process functionality:
    110110
    111111{{{
    112 1. 
    113 2.
     1121.  ''Main Thread''
     113    create the new receiving thread       /* this thread (2.) will receive TCP message */
     114    WHILE (true)
     115       message = recv(pipe)               /* receive message from NodeHandler*/
     116       IF (messgage != "SHUTDOWN")
     117           SendReliableBroadcast(message)
     118       ELSE
     119           initiate graceful shutdown
     120       END IF
     121    END WHILE
    114122
     123    FUNCTION SendReliableBroadcast(message)
     124       IF (first invocation)              /* sp that the Socket is created only once */
     125          open a new Broadcast Server Socket
     126       END IF
     127       Setup ACK list
     128       WHILE (ACK_LIST_INCOMPLETE)
     129         sendto(BROADCAST_ADDR, message)  /* send/resend the message */
     130         sleep(50ms)
     131       END WHILE
     132    END FUNCTION
     133 
     1342. ''Receiving Thread''
     135   create a new TCP connection
     136   bind
     137   listen(400)
     138   WHILE (true)
     139     accept(a connection)
     140     read(message)
     141     IF (message == ACK)
     142        lock(ACK_list)
     143        update ACK list
     144        IF (ACK_LIST_COMPLETE)
     145           send "WAKEUP" to main thread
     146        ELSE IF (ACK_LIST_INCOMPLETE && TIMEOUT)
     147           send "TIMEOUT" to main thread
     148        END IF
     149        unlock(ACK_list)
     150     ELSE IF (message == EVENT)
     151        send(pipe) message to NodeHandler
     152     END IF
     153   END WHILE
    115154}}}
    116155