mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
count.py
This commit is contained in:
18
README.adoc
18
README.adoc
@@ -14431,7 +14431,15 @@ Maybe some day someone will use this setup to study the performance of interpret
|
|||||||
|
|
||||||
==== Python
|
==== 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'
|
./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
|
./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 \
|
./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
|
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
|
==== Node.js
|
||||||
|
|
||||||
Host installation shown at: https://askubuntu.com/questions/594656/how-to-install-the-latest-versions-of-nodejs-and-npm/971612#971612
|
Host installation shown at: https://askubuntu.com/questions/594656/how-to-install-the-latest-versions-of-nodejs-and-npm/971612#971612
|
||||||
|
|||||||
11
rootfs_overlay/lkmc/python/count.py
Executable file
11
rootfs_overlay/lkmc/python/count.py
Executable file
@@ -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
|
||||||
Reference in New Issue
Block a user