From: Bin Chen on
On 2ÔÂ27ÈÕ, ÉÏÎç12ʱ03·Ö, "queengambit" <cbp...(a)cs.york.ac.uk> wrote:
> I'm sorry but i can't think of even a simple way to implement my own
> allocator & deallocator working on shared memory with items in the
> linked list are of the same size sizeof(struct my_ringnode_st).

Use an array to do the management, you can refer to:

https://gro.clinux.org/scm/cvsweb.php/%7echeckout%7e/Lingix/mm/memory.c?rev=1.3&contenttype=text/plain&cvsroot=lingix
>
> I thought of defining a new struct with two arrays, one for holding
> offset in shared memory of each item of the linked list and the other
> for the actual items. The problem with this approach is how to keep
> track of free slots in the second array so that new item can be
> allocated as any item can be removed from the linked list.
>
> struct my_shm{
> long ringnode_off[PTHREAD_THREADS_MAX];
> my_ringnode_t ringnodes_array[PTHREAD_THREADS_MAX*sizeof(struct
> my_ringnode_st)]}
>
> Please advise me on how to implement the allocator/deallocator for my
> shared memory of linked list.
>
> Thank you


From: Bin Chen on
On 2ÔÂ27ÈÕ, ÏÂÎç8ʱ09·Ö, "Bin Chen" <binary.c...(a)gmail.com> wrote:
> On 2ÔÂ27ÈÕ, ÉÏÎç12ʱ03·Ö, "queengambit" <cbp...(a)cs.york.ac.uk> wrote:
>
> > I'm sorry but i can't think of even a simple way to implement my own
> > allocator & deallocator working on shared memory with items in the
> > linked list are of the same size sizeof(struct my_ringnode_st).
>
> Use an array to do the management, you can refer to:
>
> https://gro.clinux.org/scm/cvsweb.php/%7echeckout%7e/Lingix/mm/memory...
>
BTW: This is done when I was a college student and have many defects,
just for illustration purpose, don't laugh at it.
>
>
> > I thought of defining a new struct with two arrays, one for holding
> > offset in shared memory of each item of the linked list and the other
> > for the actual items. The problem with this approach is how to keep
> > track of free slots in the second array so that new item can be
> > allocated as any item can be removed from the linked list.
>
> > struct my_shm{
> > long ringnode_off[PTHREAD_THREADS_MAX];
> > my_ringnode_t ringnodes_array[PTHREAD_THREADS_MAX*sizeof(struct
> > my_ringnode_st)]}
>
> > Please advise me on how to implement the allocator/deallocator for my
> > shared memory of linked list.
>
> > Thank you