Policy for Locking Pages in Memory

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
Whitebird
Posts: 23
Joined: Wed Feb 02, 2011 12:30 pm
Location: Belo Horizonte, Minas Gerais, Brazil
Contact:

Policy for Locking Pages in Memory

Post by Whitebird »

Hello everyone!

I have some questions regarding the policy for locking pages in memory.

1) Should I assign to each process a constant maximum number pages that it can pin in memory or should it be done dynamically?
2) If the number of pinned pages should change dynamically for each process, how can I control that?


Thank you,

White
Pedro H. Penna.

Undergraduate student of Computer Engineering.

Current OS Project: http://nanvix.blogspot.com/
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Policy for Locking Pages in Memory

Post by bluemoon »

It depends on your design.

By the way, an OS may limit the maximum memory can be allocated per user (or per process); and allocate them dynamically (on demand).
Whitebird wrote:2) If the number of pinned pages should change dynamically for each process, how can I control that?
You know when a page is allocated (syscall or page fault), and you can do some kind of bookkeeping.
Whitebird
Posts: 23
Joined: Wed Feb 02, 2011 12:30 pm
Location: Belo Horizonte, Minas Gerais, Brazil
Contact:

Re: Policy for Locking Pages in Memory

Post by Whitebird »

Thanks for answering me bluemoon.

I was aware that an OS should dynamically change the number of frames allocated per processor per-user by load control, probably using PFF as reference. But, I'm not sure if I can apply that for page locking.

For the moment, I assign to each process a constant number of pages that it can pin in memory. What do you think about this approach?

Cheers,

White
Pedro H. Penna.

Undergraduate student of Computer Engineering.

Current OS Project: http://nanvix.blogspot.com/
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Policy for Locking Pages in Memory

Post by bluemoon »

It's a matter of policy.

However, IMO, the ability to control / pin some memory (and avoid it being swapped) may impact the system, and should not be abused.
Furthermore, normal application should / would have no idea on the overall system workload and stress, so they could not help in any case by providing hints on memory usage - they usually make it worst.

That leave the only useful case for drivers, that require special treatment on memory (eg. non-swappable buffers, or things that impact performance if swapped); in such cases you may as well provide special API for such allocation.
Post Reply