Small task #2 and #2+¶
Write a program that uses threads without the help of the thread library (raw syscalls).
The program should:
- Create a new thread in the same address space – allocate the stack for the new thread, use syscall
clone
to run the code. - In the new thread: write 1000 times
"A\n"
to the standard output (using syscallwrite
), and then end the thread (syscallexit
). - In the main thread: write 1000 times
"B\n"
to the standard output (using syscallwrite
), wait for the new thread to finish (waitpid
) and then end the program (syscallexit_group
).
The task can be done in two versions:
- #2 (easy, worth 1 point): using the
clone
,syscall
functions from libc. - #2+ (difficult, worth 2 points): not using any library functions, calling syscalls from assembly language.