我会在没有root权限的实时进程to lock the memory pages上执行root
。由于最大锁定内存的用户mlockall
非常低(并且由于安全考虑而没问题),我会通过int mlockall(int flags);
用户生成的另一个进程来锁定内存。
不幸的是,int mlockall(int flags, pid_t pid);
有这个签名:
nohup /usr/hp/ism/jboss-3.2.8.SP1/bin/run.sh &
因此,仅当目标进程直接调用它时才有效。有一种方法(例如另一个系统调用)来锁定另一个进程的内存吗? 类似的东西:
using System.Threading;
using Timer = System.Timers.Timer;
internal class JobTimer : IDisposable
{
private readonly object _objectLock = new object();
private readonly ReaderWriterLockSlim timerLock = new ReaderWriterLockSlim();
private DateTime lastExec = DateTime.MinValue;
private Timer _timer;
public JobTimer()
{
this._timer = new Timer(1000);
this._timer.Elapsed += this.TimerEvent;
}
private event EventHandler JobDueEvent;
public void Start()
{
if (_timer != null)
{
_timer.Dispose();
}
this._timer = new Timer(1000);
this._timer.Elapsed += this.TimerEvent;
this._timer.Start();
var interval = 1;
this.lastExec = DateTime.UtcNow.Date.AddMinutes(
(Math.Floor(currentTime.TimeOfDay.TotalMinutes / interval) + 1) *
interval).Subtract(TimeSpan.FromMinutes(1));
}
public void Stop()
{
this._timer.Stop();
}
public void Dispose()
{
_timer.Stop();
_timer.Dispose();
}
private void TimerEvent(object timerInfo, ElapsedEventArgs args)
{
try
{
this.timerLock.EnterWriteLock();
if (lastExec.Add(TimeSpan.FromMinutes(1)) < DateTime.UtcNow)
{
lastExec = lastExec.Add(TimeSpan.FromMinutes(1));
// DO WHAT YOU WANT TO DO WHEN THE TIMER FIRES
}
}
catch (Exception ex)
{
}
finally
{
this.timerLock.ExitWriteLock();
}
}
}