[Top][All Lists]

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

Re: [lwip-users] Are sys_arch_protect/unprotect required to nest?

From: address@hidden
Subject: Re: [lwip-users] Are sys_arch_protect/unprotect required to nest?
Date: Tue, 16 Nov 2021 07:55:42 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0

Am 15.11.2021 um 15:53 schrieb Grant Edwards:
On 2021-11-15, Ajay Bhargav via lwip-users <lwip-users@nongnu.org> wrote:

sys_arch_protect() and sys_arch_unprotect() is always called in
pairs with call order maintained.

So the requirement stated in the documentation that

   SYS_ARCH_UNPROTECT Perform a "fast" set of the protection level to "lev".

is incorrect and the parameter passed to sys_arch_unprotect() may be

No and yes: it's not incorrect as the lwIP source calls it that way.
However, for some systems it's just easier to write 'lev' to some
register instead of enabling interrupts or something.

This whole macro set started out a very long time ago and has been
changed over time. If I remember correctly, at some point someone came
to the conclusion that nesting theses locks is not a good idea since it
makes porting lwIP harder. So by now, nesting is not used any more.
However, it seems this never got formalized.


 From rtos prospective, you can consider sys_arch_protect() as
enter_critical_section() and sys_arch_unprotect() as

That's only true if enter_critical_section() and
exit_critical_section() enforce nesting/paired calls.

These calls might already be provided by rtos you're using.

They are, but they do not nest. In the uItron RTOS I'm using the "exit
critical section" function re-enables context switching no matter how
many times "enter critical section" has been called. I'm working on a
nesting equivalent.

Thanks much for the clarification.

Once I'm satisfied I understand the real requirements, I'll submit a
patch for the documentation. Hopefully that will avoid in the future
the problems created when the original authors of my sys_arch.c code
interpreted the existing documentation literally.

reply via email to

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