[Top][All Lists]

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

Re: providing memory objects to users

From: Neal H. Walfield
Subject: Re: providing memory objects to users
Date: 14 Jun 2002 10:59:02 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2

> Can you please verify with me that the following code matches what you
> described here:
> > You do not even have to do this.  Just hold a reference to the regions
> > returned by pager_write_page; it is up to you to vm_deallocate them.
> error_t
> pager_write_page (struct user_pager_info *upi, vm_offset_t page,
>                   vm_address_t buf)
> {
>   assert (upi->memobj_pages[page / vm_page_size] == (vm_address_t) NULL);
>   upi->memobj_pages[page / vm_page_size] = buf;
>   return 0;
> }

This is fine--assuming that you set upi->memobj_pages[page /
vm_page_size] to NULL in pager_read_page.

> /* Implement the pager_clear_user_data callback from the pager library. */
> void
> pager_clear_user_data (struct user_pager_info *upi)
> {
>   int idx;
>   for (idx = 0; idx < upi->memobj_npages; idx++)
>     if (upi->memobj_pages[idx])
>       vm_deallocate (mach_task_self (), upi->memobj_pages[idx], vm_page_size);
>   free (upi);
> }

Are you sure that this is what you want to do?  pager_clear_user_data
means that once there are no more senders (i.e. to the pager), the
pager will be destroyed.  Typically, you want to hold on to the actual
contents, e.g. tmpfs: if I write data into a file and close it, when I
come back ten minutes later, I would like it to still be there.

reply via email to

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