September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
14
Task/Fork/BaCon/fork.bacon
Normal file
14
Task/Fork/BaCon/fork.bacon
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
' Fork
|
||||
pid = FORK
|
||||
IF pid = 0 THEN
|
||||
PRINT "I am the child, my PID is:", MYPID
|
||||
ENDFORK
|
||||
ELIF pid > 0 THEN
|
||||
PRINT "I am the parent, pid of child:", pid
|
||||
REPEAT
|
||||
PRINT "Waiting for child to exit"
|
||||
SLEEP 50
|
||||
UNTIL REAP(pid)
|
||||
ELSE
|
||||
PRINT "Error in fork"
|
||||
ENDIF
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
import posix
|
||||
|
||||
var pid = fork()
|
||||
if pid < 0:
|
||||
# error forking a child
|
||||
elif pid > 0:
|
||||
# parent, and pid is process id of child
|
||||
else:
|
||||
# child
|
||||
quit()
|
||||
# further Parent stuff here
|
||||
15
Task/Fork/OoRexx/fork-1.rexx
Normal file
15
Task/Fork/OoRexx/fork-1.rexx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
sub=.fork~new
|
||||
sub~sub
|
||||
Call syssleep 1
|
||||
Do 3
|
||||
Say 'program ' time()
|
||||
Call syssleep 1
|
||||
End
|
||||
|
||||
::class fork
|
||||
:: method sub
|
||||
Reply
|
||||
Do 6
|
||||
Say 'subroutine' time()
|
||||
Call syssleep 1
|
||||
End
|
||||
15
Task/Fork/OoRexx/fork-2.rexx
Normal file
15
Task/Fork/OoRexx/fork-2.rexx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
sub=.fork~new
|
||||
sub~start('start_working')
|
||||
|
||||
Call syssleep 1
|
||||
Do 3
|
||||
Say 'program ' time()
|
||||
Call syssleep 1
|
||||
End
|
||||
|
||||
::class fork
|
||||
:: method start_working
|
||||
Do 6
|
||||
Say 'subroutine' time()
|
||||
Call syssleep 1
|
||||
End
|
||||
|
|
@ -1,32 +1,71 @@
|
|||
extern fork
|
||||
extern printf
|
||||
; x86_64 linux nasm
|
||||
|
||||
%include "/home/james/Desktop/ASM_LIB/Print.asm"
|
||||
%include "/home/james/Desktop/ASM_LIB/Sleep.asm"
|
||||
|
||||
section .data
|
||||
|
||||
parent: db "Parent: "
|
||||
child: db "Child: "
|
||||
newLine: db 10
|
||||
|
||||
section .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
call fork
|
||||
cmp eax, 0
|
||||
je _child
|
||||
jg _parent
|
||||
jmp _exit
|
||||
|
||||
_parent:
|
||||
push p_msg
|
||||
call printf
|
||||
jmp _exit
|
||||
_child:
|
||||
push c_msg
|
||||
call printf
|
||||
jmp _exit
|
||||
|
||||
_exit:
|
||||
push 0x1
|
||||
mov eax, 1
|
||||
push eax
|
||||
int 0x80
|
||||
ret
|
||||
|
||||
section .data
|
||||
c_msg db "Printed from Child process",13,10,0
|
||||
p_msg db "Printed from Parent process",13,10,0
|
||||
|
||||
global _start
|
||||
|
||||
_start:
|
||||
mov rax, 57 ; fork syscall
|
||||
syscall
|
||||
cmp rax, 0 ; if the return value is 0, we're in the child process
|
||||
je printChild
|
||||
|
||||
printParent: ; else it's the child's PID, we're in the parent
|
||||
|
||||
mov rax, 1
|
||||
mov rdi, 1
|
||||
mov rsi, parent
|
||||
mov rdx, 8
|
||||
syscall
|
||||
|
||||
mov rax, 39 ; sys_getpid
|
||||
syscall
|
||||
mov rdi, rax
|
||||
call Print_Unsigned
|
||||
|
||||
mov rax, 1
|
||||
mov rdi, 1
|
||||
mov rsi, newLine
|
||||
mov rdx, 1
|
||||
syscall
|
||||
|
||||
mov rdi, 1 ; sleep so the child process can print befor the parent exits
|
||||
call Sleep ; you might not see the child output if you don't do this
|
||||
|
||||
jmp exit
|
||||
|
||||
printChild:
|
||||
|
||||
mov rdi, 1
|
||||
call Sleep ; sleep and wait for parent to print to screen first
|
||||
|
||||
mov rax, 1
|
||||
mov rdi, 1
|
||||
mov rsi, child
|
||||
mov rdx, 7
|
||||
syscall
|
||||
|
||||
mov rax, 39 ; sys_getpid
|
||||
syscall
|
||||
mov rdi, rax
|
||||
call Print_Unsigned
|
||||
|
||||
mov rax, 1
|
||||
mov rdi, 1
|
||||
mov rsi, newLine
|
||||
mov rdx, 1
|
||||
syscall
|
||||
|
||||
exit:
|
||||
mov rax, 60
|
||||
mov rdi, 0
|
||||
syscall
|
||||
|
|
|
|||
1
Task/Fork/Zkl/fork.zkl
Normal file
1
Task/Fork/Zkl/fork.zkl
Normal file
|
|
@ -0,0 +1 @@
|
|||
zkl: System.cmd("ls &")
|
||||
Loading…
Add table
Add a link
Reference in a new issue