In the book "The design and implementation of the FreeBSD Operating System",
it explain the return value of system call as below.
I have some questions:
1. Is the success/fail flag passed by the carry bit of psw or eax?
2. when to set the value of errno?
it explain the return value of system call as below.
I have some questions:
1. Is the success/fail flag passed by the carry bit of psw or eax?
2. when to set the value of errno?
Eventually, the system call returns to the calling process, either successfully or unsuccessfully. On the PC architecture, success or failure is returned as the carry bit in the user process's program status longword: If it is zero, the return was successful; otherwise, it was unsuccessful. On many machines, return values of C functions are passed back through a general-purpose register (for the PC, data register EAX). The routines in the kernel that implement system calls return the values that are normally associated with the global variable errno. After a system call, the kernel system-call handler leaves this value in the register. If the system call failed, a C library routine moves that value into errno, and sets the return register to -1. The calling process is expected to notice the value of the return register, and then to examine errno. The mechanism involving the carry bit and the global variable errno exists for historical reasons derived from the PDP-11.