[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] sys_arch_protect return value
From: |
Mason |
Subject: |
[lwip-users] sys_arch_protect return value |
Date: |
Fri, 20 Jan 2012 17:09:25 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20111221 Firefox/9.0.1 SeaMonkey/2.6.1 |
Hello,
According to sys_arch.txt
sys_prot_t sys_arch_protect(void)
This optional function does a "fast" critical region protection and returns
the previous protection level. This function is only called during very short
critical regions. An embedded system which supports ISR-based drivers might
want to implement this function by disabling interrupts. Task-based systems
might want to implement this by using a mutex or disabling tasking. This
function should support recursive calls from the same task or interrupt. In
other words, sys_arch_protect() could be called while already protected. In
that case the return value indicates that it is already protected.
I'm using OS21 (STMicro) and I've decided to use a mutex.
Is it correct that, in my case, I can ignore the sys_prot_t
arguments?
My implementation (in sys_arch.c)
typedef int sys_prot_t;
static mutex_t *sys_arch_mutex;
void sys_init(void) { sys_arch_mutex = mutex_create_fifo( ); }
sys_prot_t sys_arch_protect(void)
{
mutex_lock(sys_arch_mutex);
return 0;
}
void sys_arch_unprotect(sys_prot_t pval)
{
mutex_release(sys_arch_mutex);
}
--
Regards.
- [lwip-users] sys_arch_protect return value,
Mason <=