我正在 WSL 上运行 NASM x86_64 位程序集。我本来期望 syscall_vfork 并行执行进程,但它只是运行父进程,然后运行子进程。
bits 64
default rel
%include "stringfns.asm" ; basic print functionality
section .data
count: dw 0
section .text
global main
main:
mov r15, 0
spawner:
mov rax, 58
syscall
cmp rax, 0
je child
call debug ; prints 0\n, occurs after child has finished
inc r15
cmp r15, 16
jne spawner
jmp exit
child:
mov r15, 0
.loop:
inc r15
cmp r15, 1000 ; execute child for some amount of time
jne .loop
inc word [count]
xor rsi, rsi
mov si, [count]
call iprintln ; prints integer in rsi
exit:
mov rax, 60
mov rdi, 0
syscall
我还将最大并行线程设置为十六,但没有效果