Calling exit (1) and REUTRN 1 in main is equivalent.
The only way for the kernel to start a process is to call exec, and the only way the user program terminates the process is to display or implicitly invoke _exit or exit.
Each process will have a process table. The process table is a global pointer: environ. The extern char **environ can view this environment table. In addition, you can get the Modify environment table by getenv and putenv. Write a program to try it.
Linux segment: Linux body section starting from the 0x08048000 unit, the bottom of the stack from the 0xc0000000 start
The
Stack is growing downward and growing upward. The logical address is described here.
at compile time, gcc-static can prevent programs from using dynamic libraries and instead use static libraries.
malloc: allocates the specified byte store, the value is indeterminate.
Calloc: prototype is void *calloc (size_t nobj, size_t size), assigning size*nobj bytes.
realloc: Changes the length of the previous store. Prototype: void *realloc (void *ptr, size_t new_size); The return value may be the same as the original address (if there is enough storage behind it), there may be a change (there is not enough storage in the back, you need to request a large one, and copy the original content). New_size is the size of the new buffer, not the difference. If the PTR is empty, it is equivalent to malloc, and if size is 0, it is equivalent to free. The new request was not initialized. The
returned address must be aligned so that it can store any object type. For example, some systems require that the starting address of the double type data must be a multiple of 8. The
putenv,setenv,unsetenv three functions to change the environment variables of a process.
Setenv:int setenv (const char *name, const char *value, int rewrite)//rewrite: If overwrite is already present. The
putenv function puts the parameters directly into the environment table without allocating the storage area. That way, if it's a stack, you get an error. The
setjmp and longjmp are global Goto, but try not to use them, which implies a lot of pitfalls and error-prone.
Getrlimit and Setrlimit can modify resource limits for a process. Together with the command to modify, for all the processes, this function can be for the current process. The corresponding command-type Ulimit.
Write test program validation:
1, program dead Loop, have printf, foreground boot and background boot to occupy the same CPU?
2, Open the file, and then close the file to say whether the time is too large.
Okay. Average 50us (0.05 milliseconds)
3, open large file and open a small file, occupy the same time? Is the difference big?
Open mode differs from open time (the following code: Opening a file, writing the same content):
a+:20us
w+/w:70us
r:20us
R+:20us
There is a difference between opening a large file and opening a small file.
A 8M, a 3k, also applies a + open, does not write content:
8m:37us
3k:12us
A 8M, a 3k, the same applies a + open, write content (1K):
8m:60us
3k:23us
In writing a 250M file, it's almost 60us. And 8M is not very different. After the
switch to flush, the average flush after writing is approximately 9us.
4, write files: Write the same content, write to a blank file and write to a large file, time is the same?
Almost.
5, A file, open, write content. Deletes the entire file outside the process, and then writes the file. See what effect: Can write success, the file will not be regenerated, whether it will be generated when the shutdown, whether it will return errors to know that the file does not exist, whether through errno to obtain this information.
There is no good method at this time, the return value of the Write function is successful, but the file does not exist. At present my practice is to write the time to determine whether the file exists. It takes about 9us of time. It's a lot quicker than turning it off.
6, a thread in order to write multiple files and multiple threads in parallel to write multiple files, the same amount of time to spend the same?
7, file IO when the self-caching is written to the file? Are you calling the last write function? Or is it inside the system? If it is the previous one, the write call return time is not the same.