From 9cb2f48725ac2f9f54967ced3c15d41a9bf5e3ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Thu, 16 Jan 2020 00:00:00 +0000 Subject: [PATCH] count.py --- README.adoc | 18 ++++++++++++------ rootfs_overlay/lkmc/python/count.py | 11 +++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) create mode 100755 rootfs_overlay/lkmc/python/count.py diff --git a/README.adoc b/README.adoc index af229db..d6eb690 100644 --- a/README.adoc +++ b/README.adoc @@ -14431,7 +14431,15 @@ Maybe some day someone will use this setup to study the performance of interpret ==== Python -Build and install the interpreter on the target: +Examples: + +* link:rootfs_overlay/lkmc/python/hello.py[]: hello world +* `time` +** link:rootfs_overlay/lkmc/python/count.py[]: count once every second + +===== Build and install the interpreter + +Buildroot has a Python package that can be added to the guest image: .... ./build-buildroot --config 'BR2_PACKAGE_PYTHON3=y' @@ -14473,7 +14481,9 @@ Non-interactive usage: ./run --userland "$(./getvar buildroot_target_dir)/usr/bin/python3" --userland-args rootfs_overlay/lkmc/python/hello.py .... -LKMC 50ac89b779363774325c81157ec8b9a6bdb50a2f gem5 390a74f59934b85d91489f8a563450d8321b602da: +===== Python gem5 user mode simulation + +At LKMC 50ac89b779363774325c81157ec8b9a6bdb50a2f gem5 390a74f59934b85d91489f8a563450d8321b602da: .... ./run \ @@ -14510,10 +14520,6 @@ fatal: syscall unused#278 (#278) unimplemented. which corresponds to the glorious `getrandom` syscall: https://github.com/torvalds/linux/blob/v4.17/include/uapi/asm-generic/unistd.h#L707 -Examples: - -* link:rootfs_overlay/lkmc/python/hello.py[]: hello world - ==== Node.js Host installation shown at: https://askubuntu.com/questions/594656/how-to-install-the-latest-versions-of-nodejs-and-npm/971612#971612 diff --git a/rootfs_overlay/lkmc/python/count.py b/rootfs_overlay/lkmc/python/count.py new file mode 100755 index 0000000..23e6931 --- /dev/null +++ b/rootfs_overlay/lkmc/python/count.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +# https://cirosantilli.com/linux-kernel-module-cheat#python + +import time + +i = 0 +while True: + print(i) + time.sleep(1) + i += 1