Semaphore Use for Inter Process Communication

 

#include "m2m_type.h"

#include "m2m_os_lock_api.h"

M2M_T_OS_LOCK semaphore

    .

 

    /* Initialize a semaphore for Inter Process Communication: "val" value is equal to M2M_OS_LOCK_IPC, it is

        the initial semaphore count = 0 */

        M2M_T_OS_LOCK semaphore = m2m_os_lock_init(M2M_OS_LOCK_IPC);

   

    /* The retrieved semaphore count is zero, the control is not returned to the calling task */

        m2m_os_lock_lock(semaphore);

  

    /* The current task waits till the other task unlocks the semaphore by calling m2m_os_lock_unlock(semaphore),

        the function increments the semaphore count by one */

 

    /* Destroy the semaphore */

        m2m_os_lock_destroy(semaphore);

    .