* Re: Help mlockall()
1999-03-23 5:00 Help mlockall() Stephen Burke
@ 1999-03-24 5:00 ` Jeff Denham
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Denham @ 1999-03-24 5:00 UTC (permalink / raw)
Stephen Burke wrote:
> Hi,
> My question is multipart and I apologize in advance for my lack of
> understanding of Virtual Memory, paging, swap space and
> program text and data segment therefore I will be using terms like "memory"
> rather losely.
>
> 1. We are writing an application that uses Unix in a "real-time"
> Environment, therefore before the application process starts
> it makes a call to mlockall.
>
> My understanding is that all of the data segment is currently "paged" from
> disk and "locked" into physical memory.
> (Please put me right here if I've got this wrong)
>
> This (will potentially) causes us problems, as the time it takes to "load"
> the application into physical memory causes the application to miss
> deadlines although subsequent deadlines are met.
>
> Does any "Guru" out there know of a way to make sure that all the
> application memory is initially loaded into physical memory?
There's no way to do this but to run the program. Do the mlockall()
as early as possible in main and don't enter your realtime loop
you've allocated all you memory, etc. There's no way for
the VM subsystem to know what memory you'll need and
wire it until you've touched it! If you're doing runtime allocation
and can't afford a page fault, you'll have to malloc/mmap
and manage you own heap.
There's no magic bullet here -- you've got to try your
hardest to get everything where you want before your
application start to doing its job. You've got to pay
these high start up costs up front; there's no way around
it. You've got to build that fact into your design.
Same with scheduling policy/priority. When you
main thread starts, it's going to be a vanilla timeshare
thread -- you've to get everybody in the scheduling state
you want before you begin to hope for steady-state,
predictible behavior.
>
>
> 2. When using Dynamic libraries does the call to mlockall- lock the complete
> dynamic library into physical memory.
> Static linkage would alleviate the problems of 2. but alas we were supplied
> with Third Party libraries in a Dynamic Library format.
Yes, this all works with shared libraries, but tends to be pretty
expensive (but you obviously have tons of memory or you
wouldn't be wiring it down!). When asked to wire shared
text, the VM will make a complete private copy for the
executable and wire it all down. You get you own copy
of the data anyway, but instead of marking it as copy-on-write,
the VM will allocate and wire that for you too.
>
>
> 3. Does anyone have any opinions on using Dynamic libraries in a "real-time"
> Application.
> Any help you have on the above and more importantly any where you can put me
> "right" on terminology would be greatly appreciated.
>
Just have lots of physical memory. And run in lazy swap mode,
because you won't be needing any swap space, right?
>
> Platform
> Digital Unix 4.0d
> Digital Unix C++ (6.x)
> + Loads of third party libraries.
>
I hope this is an SMP box. You best chance for predictible
performance is to partition an MP box using processor
sets (psets), and get your realtime processes over onto
their own set of processors.
Oh, and have you seen the Guide to Realtime Programming?
>
> Thanks
>
> Stephen
Hope that helps....
-- Jeff
__________________________________________________
Jeff Denham (jdenham@brighttiger.com)
Bright Tiger Technologies: Resource-management software
for building and managing fast, reliable web sites
See us at http://www.brighttiger.com
125 Nagog Park
Acton, MA 01720
Phone: (978) 263-5455 x177
Fax: (978) 263-5547
^ permalink raw reply [flat|nested] 2+ messages in thread