bug-hurd
[Top][All Lists]
Advanced

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

Re: providing memory objects to users


From: Marcus Brinkmann
Subject: Re: providing memory objects to users
Date: Fri, 14 Jun 2002 07:13:28 -0400
User-agent: Mutt/1.3.25i

On Fri, Jun 14, 2002 at 10:59:02AM +0200, Neal H. Walfield wrote:
> > 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.

I use calloc at upi creation time, and also have an assertion in
pager_read_page about this.

> > /* 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.

Actually, if you look in the code, the server holds a reference to the
memory object as long as the virtual console exists.  Whenthe virtual
console is destroyed, it will deallocate the send right, and libpager
will clean up the upi object.

The idea is that virtual consoles are created and destroyed on the fly.
On normal consoles there will always be a getty, so they will always be
in use.

Thanks,
Marcus






reply via email to

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