Program startup details | Pintos Documentation
The Pintos C library for user programs designates _start(), in lib/user/entry.c, as the entry point for user programs. This function is a wrapper around main() that calls exit() if main() returns: The kernel must put the arguments for the initial function on the stack before it allows the user program to begin executing. The arguments are passed in the same way as the normal calling convention (see 80x86 Calling Convention). Consider how to handle arguments for the following example command: /bin/ls -l foo bar. First, break the command into words: /bin/ls, -l, foo, bar. Place the words at the top of the stack. Order doesn’t matter, because they will be referenced through pointers. Then, push the address of each string plus a null pointer sentinel, on the stack, in right-to-left order. These are the elements of argv. The null pointer sentinel ensures that argv[argc] is a null pointer, as required by the C standard. The order ensures that argv[0] is at the lowest virtual address. The x86
Program startup details | Pintos Documentation Skip to main content Menu Expand (external link) Document Search Copy Copied Pintos Documentation Program startup details The Pintos C library for user programs designates _start() , in lib/user/entry.c , as the entry point for user programs. This function is a wrapper around main() that calls exit() if main() returns: void _start (int argc, char *argv[]) { exit (main (argc, argv)); } The kernel must put the arguments for the initial function on the stack before it allows the user program to begin executing. The arguments are passed in the same wa
related reading
- Intro - Putting the "You" in CPUcpu.land
- Thread functions | Pintos Documentationcs162.org
- Process Control Syscalls | CS 162 Project 1cs162.org
- The "Basics" | Putting the "You" in CPUcpu.land
- Syscalls | Pintos Documentationcs162.org
- Syscall implementation | CS 162 HW 4cs162.org
- How to execute an object file: Part 1blog.cloudflare.com
- Implementation requirements | CS 162 Project 2cs162.org
- Getting silly with C, part -5^-7 - lcamtuf’s thinglcamtuf.substack.com
- User threads | CS 162 Project 2cs162.org
- Execution of Forth Codeforth.com
- Pages | CS 162 HW 4cs162.org