RMS : Rate monotonic scheduling

更新时间:
2024-05-14
下载文档

RMS : Rate monotonic scheduling

This Rms module is Rate Monotonic Scheduler program cycle controller. Tasks can use the Rms module to achieve high precision timing cycles.

User can use the following code to import the Rms module.

var Rms = require("rms");

Support

The following shows Rms module APIs available for each permissions.

 User ModePrivilege Mode
Rms 
rms.period 

Rms Class

new Rms()

  • Returns: {Object} rms object.

Create a RMS program cycle controller object. If the current program is Privileged Mode, the system will change the current task scheduling policy to SCHED_FIFO. For the operating system scheduling policy, you can view the POSIX ( IEEE-1003 ) related specifications.

Example

var rms = new Rms();

Rms Object

rms.period(ms[, gc])

  • ms {Integer} Program execution period in milliseconds.
  • gc {Boolean} Whether to try garbage collection during delays. default: true.
  • Returns: {Boolean} Whether the loop timeout.

Control program cycle execution according to the specified period time setting.

Example

var rms = new Rms();

while (true) {
  rms.period(100);

  // The following code is executed every 100 ms.
  console.log("Hello!");
}
var rms = new Rms();

while (true) {
  if (!rms.period(100)) {
    // Expires!
    console.log("RMS period overflow!");
  }

  // If the code loop body execution time exceeds the set period, an overflow error will occur.
  sys.sleep(101);
}
文档内容是否对您有所帮助?
有帮助
没帮助