DOC PREVIEW
UNO CSCI 8530 - Memory Locking

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1CSCI 8530Advanced Operating SystemsMemory Locking2Virtual Memory and Real TimeVirtual memory is a useful feature in systems. It provides:Separation of memory spaces (e.g. process A can’t access process B’s memory)Protection for the OS from errant processesApparent contiguous memory for things like arraysThe major drawback to virtual memory is paging(and/or swapping).23PagingPaging (or more properly, page replacement) is the action taken by the system when a “new” page is needed in memory and insufficient empty page frames exist; an “empty” must be created by copying the contents of an existing “full” page to disk.Paging requires significant time (for disk I/O, invalidation of cache entries, and the cache misses that occur when a new page is brought into memory).There is no reliable way a process can predict when paging will occur.4Paging in Real-Time SystemsIn non-realtime systems, the time spent on paging isn’t a problem, since the processes are not dependent on when they’re executed. That is, they have functional, but not temporal, correctness requirements.In realtime systems, however, the uncertainty associated with paging can result in failure to meet deadlines.One approach to solving to this problem lies in locking pages in memory, thus guaranteeing that paging will not occur for those locked pages.35Locking All Pages in MemoryThe POSIX mlockallsystem call attempts to lock every page of memory accessibly by the calling process so they cannot be paged out, returning 0 on success.The single argument to mlockall specifies if only the current memory is to be locked (MCL_CURRENT), or if only future memory allocations are to be locked (MCL_FUTURE), or both (MCL_CURRENT | MCL_FUTURE).POSIX does not specify what happens if a future memory allocation would exceed the available physical memory on the system; it is your responsibility to avoid this situation.mlockallisn’t currently supported by QNX.6Unlocking All Memory PagesThe POSIX munlockallfunction undoes what mlockalldid: it unlocks the pages that were previously locked.This does not mean the unlocked pages will be immediately paged out.The function only informs the system that, if necessary, pages for the process may now be paged out.Like mlockall, munlockallisn’t currently supported by QNX.47Why Lock It All?Locking all of the memory belonging to a process is usually overkill, and might not be possible in some systems.In most cases, it is sufficient to lock down those pages that are critical to the current activities of the process.The POSIX function mlock and munlock can be used to achieve locking of specified memory regions. Neither is currently supported by QNX.8mlock and munlockThe mlockfunction takes two arguments:A void * pointer which specifies the lowest address in the memory to be lockedAn integer (actually size_t) that specifies the number of bytes to be lockedThe munlockfunction takes the same arguments.Both functions return 0 on success.59CaveatsMemory locking and unlocking is not cumulative. If you lock the same region of memory twice, and then unlock it once, it’s totally unlocked.Thus, a region of memory is either totally locked in physical memory, or not locked at all.This means that the design of a real-time application (that will run on a system that does paging) must consider locking on a global, application-wide


View Full Document

UNO CSCI 8530 - Memory Locking

Download Memory Locking
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Memory Locking and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Memory Locking 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?