tasklwIP - A Lightweight TCP/IP stack - Tasks: task #6957, make mem_free work with NO_SYS=1...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

task #6957: make mem_free work with NO_SYS=1 to free pbufs from interrupt context

Submitter:  Simon Goldschmidt <goldsimon>
Submitted:  Thu 31 May 2007 08:17:48 AM UTC
   
 
Category:  None Should Start On:  Thu 31 May 2007 12:00:00 AM UTC
Should be Finished on:  Thu 31 May 2007 12:00:00 AM UTC Priority:  1 - Later
Status:  Cancelled Privacy:  Public
Assigned to:  None Percent Complete:  0%
Open/Closed:  Closed Planned Release:  None
Effort:  0.00

Thu 21 Jun 2007 08:17:03 PM UTC, comment #2: 

I think this can be closed: simply use the option MEM_USE_POOLS if this is a problem.

Simon Goldschmidt <goldsimon>
Group administrator
Fri 08 Jun 2007 04:48:48 PM UTC, comment #1: 


> We could solve this by looking if the heap is blocked and return
> 0 on mem_malloc if so (that shouldn't happen so often since you
> don't alloc from a heap in interrupt context). mem_free could put
> the mem-structs on some kind of list that gets freed if the other
> context leaves the blocked region. That blocking could be done
> with a 'bool' that is locked by SYS_ARCH_PROTECT.


Maybe the idea isn't that good after all: we would need a call to memp_malloc() to create a list item for a struct mem to be freed.

So maybe it's simpler to move to creating pools for mem_malloc instead of the slow heap.

Any comments on this general problem?
We could also leave it like it is and document the limitation (not being able to free PBUF_RAM pbufs in interrupt context)...

Simon Goldschmidt <goldsimon>
Group administrator
Thu 31 May 2007 08:17:48 AM UTC, original submission:  

With the current implementation, with NO_SYS=1, the heap is not protected from concurrent access at all. In a no-sys, interrupt driven system, we have SYS_ARCH_PROTECT to protect things like the memp pools, but have chosen not to use this to protect the heap as it turns off interrupts for too long. The downside is that (if we have no semaphores) the heap is not protected at all, which means packets can't be freed (e.g. in a TX interrupt routine) if they are of type PBUF_RAM (as most TX packets are).

We could solve this by looking if the heap is blocked and return 0 on mem_malloc if so (that shouldn't happen so often since you don't alloc from a heap in interrupt context). mem_free could put the mem-structs on some kind of list that gets freed if the other context leaves the blocked region. That blocking could be done with a 'bool' that is locked by SYS_ARCH_PROTECT.

Any other ideas?

Simon Goldschmidt <goldsimon>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-06-21 goldsimon StatusNone Cancelled
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code