Microchip® Advanced Software Framework

lwip-1.3.2/src/core/sys.c File Reference

lwIP Operating System abstraction

#include "lwip/opt.h"
#include "lwip/sys.h"
#include "lwip/def.h"
#include "lwip/memp.h"
#include "lwip/tcpip.h"

Data Structures

struct  sswt_cb
 Struct used for sys_sem_wait_timeout() to tell wether the time has run out or the semaphore has really become available. More...
 

Functions

static void sswt_handler (void *arg)
 Timeout handler function for sys_sem_wait_timeout() More...
 
void sys_mbox_fetch (sys_mbox_t mbox, void **msg)
 Wait (forever) for a message to arrive in an mbox. More...
 
void sys_msleep (u32_t ms)
 Sleep for some ms. More...
 
void sys_sem_wait (sys_sem_t sem)
 Wait (forever) for a semaphore to become available. More...
 
int sys_sem_wait_timeout (sys_sem_t sem, u32_t timeout)
 Wait for a semaphore with timeout (specified in ms) More...
 
void sys_timeout (u32_t msecs, sys_timeout_handler h, void *arg)
 Create a one-shot timer (aka timeout). More...
 
void sys_untimeout (sys_timeout_handler h, void *arg)
 Go through timeout list (for this task only) and remove the first matching entry, even though the timeout has not triggered yet. More...
 

static void sswt_handler ( void *  arg)
static

Timeout handler function for sys_sem_wait_timeout()

Parameters
argstruct sswt_cb* used to signal a semaphore and end waiting.

References sswt_cb::psem, sys_sem_signal(), and sswt_cb::timeflag.

Referenced by sys_sem_wait_timeout().

void sys_mbox_fetch ( sys_mbox_t  mbox,
void **  msg 
)

Wait (forever) for a message to arrive in an mbox.

While waiting, timeouts (for this thread) are processed.

Parameters
mboxthe mbox to fetch the message from
msgthe place to store the message

References sys_timeo::arg, arg, sys_timeo::h, LOCK_TCPIP_CORE, LWIP_DEBUGF, memp_free(), sys_timeo::next, sys_timeouts::next, NULL, sys_arch_mbox_fetch(), SYS_ARCH_TIMEOUT, sys_arch_timeouts(), SYS_DEBUG, sys_timeo::time, and UNLOCK_TCPIP_CORE.

void sys_msleep ( u32_t  ms)

Sleep for some ms.

Timeouts are processed while sleeping.

Parameters
msnumber of milliseconds to sleep

References ERR_OK, sys_arch_sem_wait(), sys_sem_free(), sys_sem_new(), and sys_sem_wait_timeout().

void sys_sem_wait ( sys_sem_t  sem)

Wait (forever) for a semaphore to become available.

While waiting, timeouts (for this thread) are processed.

Parameters
semsemaphore to wait for

References sys_timeo::arg, arg, sys_timeo::h, LWIP_DEBUGF, memp_free(), sys_timeo::next, sys_timeouts::next, NULL, sys_arch_sem_wait(), SYS_ARCH_TIMEOUT, sys_arch_timeouts(), SYS_DEBUG, and sys_timeo::time.

int sys_sem_wait_timeout ( sys_sem_t  sem,
u32_t  timeout 
)

Wait for a semaphore with timeout (specified in ms)

Parameters
semsemaphore to wait
timeouttimeout in ms (0: wait forever)
Returns
0 on timeout, 1 otherwise

References sswt_cb::psem, sswt_handler(), sys_sem_wait, sys_timeout(), sys_untimeout(), and sswt_cb::timeflag.

Referenced by sys_msleep().

void sys_timeout ( u32_t  msecs,
sys_timeout_handler  h,
void *  arg 
)

Create a one-shot timer (aka timeout).

Timeouts are processed in the following cases:

Parameters
msecstime in milliseconds after that the timer should expire
hcallback function to call when msecs have elapsed
argargument to pass to the callback function

References sys_timeo::arg, arg, sys_timeo::h, LWIP_ASSERT, LWIP_DEBUGF, memp_malloc(), sys_timeo::next, sys_timeouts::next, NULL, sys_arch_timeouts(), SYS_DEBUG, sys_timeo::time, and U32_F.

Referenced by sys_sem_wait_timeout(), and tcpip_thread().

void sys_untimeout ( sys_timeout_handler  h,
void *  arg 
)

Go through timeout list (for this task only) and remove the first matching entry, even though the timeout has not triggered yet.

Note
This function only works as expected if there is only one timeout calling 'h' in the list of timeouts.
Parameters
hcallback function that would be called by the timeout
argcallback argument that would be passed to h

References sys_timeo::arg, sys_timeo::h, LWIP_ASSERT, memp_free(), sys_timeo::next, sys_timeouts::next, NULL, sys_arch_timeouts(), and sys_timeo::time.

Referenced by sys_sem_wait_timeout(), and tcpip_thread().