lwip-members
[Top][All Lists]
Advanced

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

Re: [lwip-members] lightweight protection


From: David Haas
Subject: Re: [lwip-members] lightweight protection
Date: Fri, 28 Feb 2003 09:04:40 -0500
User-agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.3b) Gecko/20030224

Hi,

Some History:

When I added these macros, I was being very conservative, so I only added them where I thought protection was missing and where I thought a lighter weight protection mechanism was needed. In pbuf, protection was missing almost entirely. memp.c had semaphore protection, which would work fine, but my Coldfire driver needed to allocate memory from an ISR, so I wanted to replace these with the lightweight protection. I used the #if LIGHTWEIGHT_PROT because I did'nt want to mess anything up that people were already using.

I implemented the lightweight protection on both the unix and coldfire ports.

SYS_ARCH_DECL_PROTECT is only supposed to declare a variable to keep the old protection status, not a mutex variable. The idea of the lightweight protection is that it is global in nature. That is what makes it light weight. I admit that the mutex I used to implement it on the unix port is only slightly lighter weight than a semephore. The disabling of interrupts on coldfire is really lightweight, but might not be suitable for all systems. Somebody (Marc Boucher?) implemented lightweight protection totally with macros that disabled and enabled interrupts.

At the time, I had several people comment and add suggestions for lightweight protection, which was why it was done with these macros.

Proposal:
I don't particularly like the #if SYS_LIGHTWEIGHT_PROT test at each of these places. In my opinion we could get rid of this and always use this protection mechanism when NO_SYS is 0. I think that it adds needed protection in pbuf that is always necessary when you have multiple tasks. But, I did not think we really had a consensus on what was to be done for protection, so perhaps this needs more discussion. ;-)

I would be happy to do some implementation if we think this should change, but my design criteria is still to allow a lighter weight protection mechanism which can be implemented in some systems by disabling or reducing the interrupt level.

David.

Jani Monoses wrote:

Hi
in pbuf.c SYS_ARCH_PROTECT & co are called unconditionnally while in memp.c
they are called only if SYS_LIGHTWEIGHT_PROT is 1.Any reason for this 
inconsistency?
In pbuf they seem to be an addition to semaphore locking while in memp an 
alternative.

Another question: I only see the unix arch defining these at the moment so I'm 
not sure
how they were intended to be used.Specifically  is sys_arch_decl_protect 
supposed to
declare a lock variable?In that case from the use of macros in pbuf that 
variable seems
to be local and thus does not protect from accesses from another function to 
the protected data.
Or if the lock is supposed to be global than maybe a DECL or two at the 
beginning of the file
and various protect/unprotect macro pairs in the functions would be a better 
layout.

Jani.



_______________________________________________
lwip-members mailing list
address@hidden
http://mail.nongnu.org/mailman/listinfo/lwip-members








reply via email to

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