Wednesday, January 08, 2014

Rendezvous: Creation

① Rendezvous port
 
Rendezvous ports simulate a webserver/client in a way that the accepting task waits in a port for the call from calling task. Once the pattern matches between the calling task and accepting task, Redezvous (like new connection socket id) is assigned for the combination. Once redezvous is assigned, the calling task goes into termination-waiting state waiting for the result. The accepting task gets the message from calling task and Rendezvous number. It can thread even a new task to execute the job and to reply the result to the calling task.

② ITRON implementation of cre_por()

ER cre_por(ID porid, T_CPOR *pk_cpor)
{
        Check context. If called from ISR,
                return E_CTX;
        Sanity check on arguments
        Enter critical section (Interrupt Disable)
        Allocate memory for internal port structure and waiting task queue;
        Initialize the port structure with the arguments such as max calling msg size and max returning msg size.
        Call-waiting queue and accept-waiting queue are initailized.
        (Call waiting queue is priority or FIFO based. Accept-waiting queue is FIFO based.)
        If (tasks are queued in FIFO order)
                Initialize queue as follows:
                ┏━━━━━┯━━━━━━┓
                ┃Queue   │Queue     ┃
                ┃[0]     │Tail       ┃
                ┗━━━━━┷━━━━━━┛
        else (tasks are queued as priority based)
                Initialize as follows:
                ┏━━━━━━━━┯━━┯━━━━┯━━━━━━┓
                ┃Priority0      │1   │Max   │Queue    ┃
                ┃            │    │Pri    │Tail       ┃
                ┗━━━━━━━━┷━━┷━━━━┷━━━━━━┛
        Exit critical section (Interrupt Restore)
        return ercd;
}

Many patients synchronized with many doctors through single receptionist!

No comments: