A neat way to implement a pager is to memory map a file to make it shared virtual memory. Then you need some form of mutex to synchronize access to it. If you are sharing it between processes or threads you need a lock flag on each page. If you make your shared area a named file rather than an anonymous space and write through it your cache can be persistent.

You may need a free list of deleted pages to avoid checkerboarding.

The benefit of the virtual memory approach is that you are not constrained by available memory and your application becomes more portable.

Cesar Rodas wrote:
Here a Mini doc of what is a Pager for me.. or how I understand.. please
help me to understand better :D

thanks to all

http://pdbm.sourceforge.net/pager.html

On 18/01/07, John Stanton <[EMAIL PROTECTED]> wrote:


You may find that adding backward pointers will allow you to do
deletions better.

Cesar Rodas wrote:
> project called, PDBM.
>
> The project is DBM like project, with a B+tree, and key -> value data,
> similar to BDB, QDBM or GDBM.
>
> For that project I need implement a Pager system.
>
> As I understand a Page is the minimum IO block, and a Data could have
more
> than a Page but a Page just one Data.. Am I right?
>
> Here I will write you my structures... please correct me if i am
wrong...
>
>
> /*
> **    This is the Page 0. This is a special Page that have information
> ** about total of pages, total of allocated but free pages, a pointer
to
> the
> **    first and last allocated but free pages.
> */
> typedef struct MainPage
> {
>    unsigned char lock;
>    size_t first_free;
>    size_t last_free;
>    size_t total;
>    size_t free;
> } MainPage;
>
>
> /*
> **    The pager struct.  A page is a chunk of 1024 bytes of data.
> **    A data cold have more than a page, but a page could have only
> **    a data. So a Page is the minimun allocated space for a data.
> */
> typedef struct Pager
> {
>
> /***********************************************/
>
>    unsigned char lock;       /* 1-Byte, if the Page is locked.
> */
>    size_t main;              /* 4-Byte, a pointer to the begin of the
data
> */
>    size_t next;              /* 4-Byte, a pointer to the next Page
position
> */
>    unsigned char file;       /* 1-Byte, In what file part if the next
Pager
> */
>    unsigned char data[1024]; /* 1 KB, the content of a Page
> */
>
> /***********************************************/
> } Pager;
>
> #define PAGER_LOCKED 0xAF
> #define PAGER_UNLOCK 0xFF
>
>



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]

-----------------------------------------------------------------------------






-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to