mx_task

A simple to use MATLAB library for "real-time" multi-tasking.

https://github.com/carl0sma/mx_task

現在この提出コンテンツをフォロー中です。

# mx_task
A simple to use MATLAB library for "real-time" multi-tasking.

Multitasking with tic-toc and robotics.Rate require full CPU usage which is sometimes undesired.

The new mx_task class allows users to achieve an almost real-time multitasking functionality in MATLAB, whilst not requiring full CPU usage.

---
Supports Linux and Windows. Linux systems generally have a better RT behaviour.

Functionality verified on:
- a 18.04LTS machine with MATLAB R2016b and R2019a,
- a Windows 10 machine with MATLAB R2018b.

Example 0 shows the basic functionalities of the mx_task library.

Example 1 shows how to implement multi-tasking.

Example 2 is a benchmarking script for comparisons between the scheduling capabilities of mx_task, tictoc, and robotics.Rate.

# Usage
1. First define a task with a function and affix it to a new mx_task instance. Define the desired task period at the second input.

myTask = mx_task(@()myFunc, 1/10);

function myFunc()

fprintf("Hello world.\n");

end

2. Capture the start time in [seconds since epoch] with mx_sleep().

time_start = mx_sleep(0); % sleeps for 0 seconds

time_now = time_start;

3. Create a while loop with a simulation time trap in the condition. mx_sleep for 1us for an almost real-time scheduling quality. Run task by task.run(time_now).

while (time_now <= time_start + 10) % run tasks for 10 seconds.

time_now = mx_sleep(1/1000000); % 1MHz scheduler frequency. Set to mx_sleep(0) for an enhanced real-time behaviour (at 100% CPU though).

myTask.run(time_now);

end

# Installation
Move to the mx_task directory and run the install script.

引用

Carlos Ma (2026). mx_task (https://github.com/carl0sma/mx_task), GitHub. に取得済み.

カテゴリ

Help Center および MATLAB AnswersProfile and Improve Performance についてさらに検索

MATLAB リリースの互換性

  • R2016b 以降 R2019a 以前と互換性あり

プラットフォームの互換性

  • Windows
  • macOS
  • Linux

GitHub の既定のブランチを使用するバージョンはダウンロードできません

バージョン 公開済み リリース ノート Action
1.0.2

Validated Windows compatibility. A Linux system is still recommended for superior RT performances.

1.0.1

Validated Windows support, although its RT behaviour is much worse than at on a Linux system.

1.0.0

この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。
この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。