This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Memory access violation


Hi everybody,

The fixed memory pool do not completely fulfil my requirements:
* I have several communication adapters, which support routing between
them. Each adapter has his own reception pool.
* Each adapter has a thread associated.
* As the packets are quite big and the reception buffers quite small I
waste too many entries due to the overhead associated to the pools.
* I swap packets between the different pools (plenty of long memcpys),
because as the different adapters have different speeds (and
priorities) I cannot afford having entries in a fast adapter's pool
waiting to be realeased from a slow adapter.

So :
* I have implemented my own memory structure using double linked lists.
* All this is encapsulated in a static C++ class (instead of using a
non-static class with constructor I use a method initPool).
* All the members are also static. All the nodes from the different
lists are allocated in a single common static array: static entry
pool[450], where entry is a packed struct (with entries of type byte)
of about 1Kb.
* The pool is initialized in the main Thread
* I have built a C binding for the class
* Atomicity is got by using a mutex for each adapter for the list head.

The point is that when I try to change any data of the payload of the
pool entry, a memory access violation exception is raised. I also
tried using a non-static class and the list nodes as public and
private, and also using as node array a global C node array and I
always get that exception even when only a single thread is running.
What am I doing wrong?  Shouldn't data declared in C++ as static be
common to all the objects in the threads without ownership
restrictions, even between different threads?

I would reallly apreciate if somebody could give me a hand. Thanks on advice.

Best Regards,
Marcos

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]