lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] LwIP multithread select mode problems


From: Joel Cunningham
Subject: Re: [lwip-users] LwIP multithread select mode problems
Date: Fri, 24 Jun 2016 12:50:12 +0000 (GMT)

Yes you need SYS_ARCH_PROTECT in a multi-threaded environment.  Whether or not you use SYS_LIGHTWEIGHT_PROT just controls whether the function prototypes are produced and used in SYS_ARCH_PROTECT:

#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)

sys_prot_t sys_arch_protect(void);
void sys_arch_unprotect(sys_prot_t pval);

See the comments for how these should be implemented, you can use either interrupt disable/enable, semaphore or mutex

You can also define SYS_ARCH_PROTECT directly in sys_arch.h rather than going through a layer of sys_arch functions

Example:

sys_arch.h:
#define SYS_ARCH_DECL_PROTECT(lev) cpu_flags
#define SYS_ARCH_PROTECT(lev) level = disable_interrupts()
#define SYS_ARCH_UNPROTECT(lev) enable_interrupts(lev)

Joel

On Jun 23, 2016, at 09:33 PM, lampo <address@hidden> wrote:

thank you ! Joel

I still want to know if /SYS_ARCH_PROTECT/ is a must in multiple
threads environment?
I see a lot of /SYS_ARCH_PROTECT/ in select() and other sockets apis.

But when I set /SYS_LIGHATWEIGHT_PROT/ to 1 to use *SYS_ARCH_PROTECT*, the
applicaton run into hardfault or stackoverflow(due to RTOS thread scheduler,
or deadlock something ), I tried disabling interrupts and mutex both , in
implementing SYS_ARCH_PROTECT, both not ok.

I wonder if should use SYS_ARCH_PROTECT plus LWIP_NETCONN_SEM_PER_THREAD ?

Really appreciate!



--
View this message in context: http://lwip.100.n7.nabble.com/LwIP-multithread-select-mode-problems-tp26561p26573.html
Sent from the lwip-users mailing list archive at Nabble.com.

_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

reply via email to

[Prev in Thread] Current Thread [Next in Thread]