Apache NuttX is a mature, real-time embedded operating system (RTOS)
Go to file
yinshengkai f44a31c337 procfs: add memory pressure notification support
This is a memory monitoring interface implemented with reference to Linux's PSI (Pressure Stall Information),
which can send notifications when the system's remaining memory is below the threshold.

The following example code sets two different thresholds.
When the system memory is below 10MB, a notification is triggered.
When the system memory is below 20 MB, a notification (POLLPRI event) is triggered every 1s.

```
int main(int argc, FAR char *argv[])
{
  struct pollfd fds[2];
  int ret;

  if (argc == 2)
    {
      char *ptr = malloc(1024*1024*atoi(argv[1]));
      printf("Allocating %d MB\n", atoi(argv[1]));
      ptr[0] = 0;
      return 0;
    }

  fds[0].fd = open("/proc/pressure/memory", O_RDWR);
  fds[1].fd = open("/proc/pressure/memory", O_RDWR);
  fds[0].events = POLLPRI;
  fds[1].events = POLLPRI;

  dprintf(fds[0].fd, "%llu -1", 1024LLU*1024 * 10);
  dprintf(fds[1].fd, "%llu 1000000", 1024LLU*1024 * 20);

  while (1)
    {
      ret = poll(fds, 2, -1);
      if (ret > 0)
        {
          printf("Memory pressure: POLLPRI, %d\n", ret);
        }
    }

  return 0;
}
```

https://docs.kernel.org/accounting/psi.html
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-25 23:09:28 +08:00
.github ISSUE_TEMPLATE: Fixed incorrect links for issue forms 2024-08-05 15:35:48 -03:00
Documentation nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
arch nuttx/mps2: Support NuttX running on qemu cortex-m7 2024-08-25 22:56:46 +08:00
audio nuttx/audio: Add amr and opus format control switches 2024-08-23 08:57:00 +08:00
binfmt nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
boards nuttx/mps2: Support NuttX running on qemu cortex-m7 2024-08-25 22:56:46 +08:00
cmake cmake: fix invalid syntax when generating version.h from tags 2024-08-21 23:32:09 +08:00
crypto nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
drivers pty: use mutex to protect alloc minor 2024-08-25 22:16:53 +08:00
dummy build: add initial cmake build system 2023-07-08 13:50:48 +08:00
fs procfs: add memory pressure notification support 2024-08-25 23:09:28 +08:00
graphics nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
include procfs: add memory pressure notification support 2024-08-25 23:09:28 +08:00
libs nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
mm nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
net nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
openamp nuttx/atomic.h:replace ALL stdatomic.h with nuttx/stdatomic.h in nuttx/ 2024-08-22 01:44:29 +08:00
pass1
sched nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
syscall fs:notify add support for inotify 2024-08-22 01:50:37 +08:00
tools swift6 embedded support 2024-08-23 09:02:20 +08:00
video build: add initial cmake build system 2023-07-08 13:50:48 +08:00
wireless nuttx: fix multiple 'FAR', 'CODE' and style issues 2024-08-25 19:22:15 +08:00
.asf.yaml
.gitignore greenhills: update .gitignore to exclude ghs build intermediate files 2024-08-24 20:43:53 +08:00
.pre-commit-config.yaml Created pre-commit config file 2024-08-19 21:40:56 +02:00
.yamllint
AUTHORS AUTHORS: add Tomek CEDRO to the list 2023-03-07 14:15:55 +01:00
CMakeLists.txt CMakeLists.txt: warning D9002 on windows + msvc 2024-08-22 08:28:34 +08:00
CONTRIBUTING.md Remove the tail spaces from all files except Documentation 2023-02-26 13:24:24 -08:00
INVIOLABLES.md
Kconfig make/disassembly: generate disassembly file 2024-08-16 15:22:25 +08:00
LICENSE libc/x86_64: port string functions from bionic 2024-07-02 23:59:18 +08:00
Makefile
NOTICE
README.md Gathering community recommendations 2023-10-28 13:55:56 +08:00
ReleaseNotes Documentation: move ReleaseNotes 2023-09-26 20:41:00 +08:00

README.md

POSIX Badge License Issues Tracking Badge Contributors GitHub Build Badge Documentation Badge

Apache NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. Scalable from 8-bit to 64-bit microcontroller environments, the primary governing standards in NuttX are POSIX and ANSI standards. Additional standard APIs from Unix and other common RTOSs (such as VxWorks) are adopted for functionality not available under these standards, or for functionality that is not appropriate for deeply-embedded environments (such as fork()).

For brevity, many parts of the documentation will refer to Apache NuttX as simply NuttX.

Getting Started

First time on NuttX? Read the Getting Started guide! If you don't have a board available, NuttX has its own simulator that you can run on terminal.

Documentation

You can find the current NuttX documentation on the Documentation Page.

Alternatively, you can build the documentation yourself by following the Documentation Build Instructions.

The old NuttX documentation is still available in the Apache wiki.

Supported Boards

NuttX supports a wide variety of platforms. See the full list on the Supported Platforms page.

Contributing

If you wish to contribute to the NuttX project, read the Contributing guidelines for information on Git usage, coding standard, workflow and the NuttX principles.

License

The code in this repository is under either the Apache 2 license, or a license compatible with the Apache 2 license. See the License Page for more information.