Reputation: 405
I am porting a HP-UX program to Linux. There IS
plock(PROCLOCK);
Should I use mlock()
to instead of it?
Also the original code did not call plock(UNLOCK)
, not sure why, but I should add munlock()
?
Upvotes: 1
Views: 336
Reputation: 137398
The SunOS 5.10 man page for plock(3C)
says:
USAGE
The
mlock(3C)
andmlockall(3C)
functions are the preferred interfaces for process locking.
Considering plock
is not available in Linux, yes mlock
is the correct alternative.
The Linux man page for mlock()
says:
Memory locking has two main applications: real-time algorithms and high-security data processing.
If your application falls under one of those two categories, then I would say yes, it makes sense to call mlock()
. I can't think of any reason you would call munlock
, but your specific program requirements may be different.
The man page has further guidance on how exactly you should call it to attain the desired results. Without knowing what your program does, or why the original author decided to call plock
, that's the best advice I can give.
Upvotes: 2