Simplified thread example
This commit is contained in:
@ -1,22 +1,14 @@
|
||||
import mem
|
||||
import sys
|
||||
import thread
|
||||
|
||||
main() {
|
||||
start(thread)
|
||||
start(thread)
|
||||
start(thread)
|
||||
thread()
|
||||
thread.create(work)
|
||||
thread.create(work)
|
||||
thread.create(work)
|
||||
work()
|
||||
}
|
||||
|
||||
start(func Pointer) {
|
||||
size := 4096
|
||||
stack := mem.alloc(size)
|
||||
rip := stack + size - 8
|
||||
store(rip, 8, func)
|
||||
sys.clone(0x100|0x200|0x400|0x800|0x8000|0x10000|0x80000000, rip)
|
||||
}
|
||||
|
||||
thread() {
|
||||
work() {
|
||||
sys.write(1, "[ ] start\n", 10)
|
||||
sys.write(1, "[x] end\n", 8)
|
||||
sys.exit(0)
|
||||
|
Reference in New Issue
Block a user