HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 29 (of 101)
Chapter 11 Software Development
October 29, 2013
calling exit()
calling exec()
receiving a signal that causes abnormal termination.
If a process aborts with a coredump, the core file will always be written to the working directory
of the process.
Although we do not call exit() explicitly in the HelloWorld.c source code, the system call
exit() is called automatically after reaching the end of main(), to terminate the process
normally:
exit(13) ......................................... WIFEXITED(13)
The exit code of our program is 13, which is the number of bytes written by the write() system
call. printf() uses write() to print the text and forwards its return code to the calling function.
Process Memory
When debugging a process or core file, it is often necessary to understand and analyze how the
process uses its address space, which contains all code and data owned by the process. This
section will give an overview about HP-UX process memory management. For a detailed
description see the "HP-UX Memory Management White Paper", Part I and II and the "HP-UX
Process Management White Paper", Part I, II and III available at the ITRC.
Quadrants
Every 32-bit process can allocate up to 2^32 = 4 Gbyte of memory. This is the address space of
the process. On HP-UX, this address space is divided into 4 quadrants with 1 GB and different
purposes for each:
Quadrant
Address Range
Usage
Q1
0x00000000 - 0x3fffffff
text
Q2
0x40000000 - 0x7fffffff
private data
Q3
0x80000000 - 0xbfffffff
shared text/data
Q4
0xc0000000 - 0xffffffff
shared text/data
The program code is loaded to the start of Q1 (0x0). In terms of process memory, program code
is also called text.