No, I am not assuming mutext required to be nested either. Infact my implementation had only simple lock unlock only. And as far as I know, lwip do not use nesting of lock, as its obvious that not all system support recursion.
And lev is usually common return value of isr flags when disable_irq or enter_critical is called in most systems and is not a mandatory requirement either. Based on your implementation, You may simply return a 0 in protect and not use lev in unprotect at all. Regards, Ajay Bhargav On Mon, Nov 15, 2021, 10:03 PM Grant Edwards <grant.b.edwa...@gmail.com> wrote: > On 2021-11-15, Ajay Bhargav via lwip-users <lwip-users@nongnu.org> wrote: > > > protect/unprotect is totally implementation dependent with only > > intention of providing exclusive access to network related operation > > to be performed without any context switching. You can do this by > > using a mutext in simplest way > > Are you assuming that mutex lock/unlock nest? Not all OSes provide > nesting/recursive mutexes. > > > but you have to make sure ISR do not do any operation either when > > system is locked, > > Yes, I understand that. > > > this can be implemented with a complex implementation but still > > possible. I have dealt with such system in past where critical > > section APIs were not possible to use and only possible option was > > to use a mutex. > > > lev may or may not be used which again depends on your > > implementation. > > If it is used, is it supposed to override the nesting? The > documentation states that sys_arch_unprotect(lev) sets the protection > level to `lev`. What is the correct behavor if that `lev` conflicts > with the call nesting level? > > > For your RTOS where nested critical section is not possible, > > I didn't say it wasn't possible, I said it wasn't provided. I've now > added a nesting version of of the RTOS calls to enter/exit critical > section. I just needed to know if nesting was required (it's not > stated in the documentation). > > > Disabling of context switch is the only requirement of lwip when it > > comes to protect/unprotect. > > I thought the nesting behavior was also a requirement? > > > Implementation is upon the programmer depending on system. > > Right. I have no problem implementing the requirements. I'm just > trying to figure out what the requirements actually _are_. > > -- > Grant > > > _______________________________________________ > lwip-users mailing list > lwip-users@nongnu.org > https://lists.nongnu.org/mailman/listinfo/lwip-users >
_______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users