Main Content

Execute Real-Time Application with S-Functions in Run in Kernel Mode

You can use S-functions in Run in Kernel mode when the S-functions are self-contained. For example, the S-functions only call a limited subset of the standard C library, such as math and string functions and do not call file I/O, console I/O, or Windows API functions. An example of not-self-contained S-function would be a function that needs to #include <windows.h>.

Note that being able to simulate an S-function with other code generation targets —such as grt.tlc or ert.tlc —does not a prove that it can be simulated with sldrt.tlc. For example, S-functions that are linked with dynamically linked libraries (DLLs) on Windows generally do not simulate with Simulink® Desktop Real-Time™ because the DLLs are not available to the real-time kernel.

In particular, the following functions are not supported in the C source code:

  • File I/O (fopen and others)

  • Process management (spawn, exit, and others)

  • Signals and exceptions (signal, longjmp, __try and others)

  • Time functions (clock and others)

  • Any functions from the Windows API

The following C library functions are supported for use with Simulink Desktop Real-Time:

  • Data conversion functions: abs, atof, atoi, atol, itoa, labs, ltoa, strtod, strtol, strtoul, ultoa,

  • Memory allocation functions: calloc, free, malloc,

  • Memory manipulation functions: _memccpy, memcpy, memchr, memcmp, _memicmp, memmove, memset,

  • String manipulation functions: strcat, strchr, strcmp, strcpy, strcspn, _strdup, _stricmp, strlen, _strlwr, strncat, strncmp, strncpy, _strnset, strpbrk, strrchr, _strrev, _strset, strspn, strstr, strtok, _strupr,

  • Mathematical functions: acos, asin, atan, atan2, ceil, cos, cosh, div, exp, fabs, floor, fmod, frexp, ldexp, ldiv, log, log10, max, min, modf, pow, rand, sin, sinh, sqrt, srand, tan, tanh, uldiv,

  • Character class tests and conversion: isalnum, isalpha, _isascii, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit, isxupper, isxlower, _toascii, tolower, toupper,

  • Searching and sorting: bsearch, qsort,

  • Dummy functions - (can be there but do nothing) exit,

  • Console I/O: fprintf, printf,

Related Topics