lwIP 2.1.1 Lightweight IP stack

Macros
Critical sections
lwIP » Porting (system abstraction layer)

## Macros
#define | SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev
#define | SYS_ARCH_PROTECT(lev) lev = sys_arch_protect()
#define | SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev)

## Detailed Description

Used to protect short regions of code against concurrent access.

- Your system is a bare-metal system (probably with an RTOS) and interrupts are under your control: Implement this as LockInterrupts() / UnlockInterrupts()
- Your system uses an RTOS with deferred interrupt handling from a worker thread: Implement as a global mutex or lock/unlock scheduler
- Your system uses a high-level OS with e.g. POSIX signals: Implement as a global mutex

## Macro Definition Documentation

## ◆ SYS_ARCH_DECL_PROTECT

#define SYS_ARCH_DECL_PROTECT | ( |  | lev | ) | sys_prot_t lev

SYS_LIGHTWEIGHT_PROT define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection for certain critical regions during buffer allocation, deallocation and memory allocation and deallocation.

SYS_ARCH_DECL_PROTECT declare a protection variable. This macro will default to defining a variable of type sys_prot_t. If a particular port needs a different implementation, then this macro may be defined in sys_arch.h.

## ◆ SYS_ARCH_PROTECT

#define SYS_ARCH_PROTECT | ( |  | lev | ) | lev = sys_arch_protect()

SYS_ARCH_PROTECT Perform a "fast" protect. This could be implemented by disabling interrupts for an embedded system or by using a semaphore or mutex. The implementation should allow calling SYS_ARCH_PROTECT when already protected. The old protection level is returned in the variable "lev". This macro will default to calling the sys_arch_protect() function which should be implemented in sys_arch.c. If a particular port needs a different implementation, then this macro may be defined in sys_arch.h

## ◆ SYS_ARCH_UNPROTECT

#define SYS_ARCH_UNPROTECT | ( |  | lev | ) | sys_arch_unprotect(lev)

SYS_ARCH_UNPROTECT Perform a "fast" set of the protection level to "lev". This could be implemented by setting the interrupt level to "lev" within the MACRO or by using a semaphore or mutex. This macro will default to calling the sys_arch_unprotect() function which should be implemented in sys_arch.c. If a particular port needs a different implementation, then this macro may be defined in sys_arch.h