ALT by Bilal Ahmed Shaik - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

img201.png

 

  Memory Management

 

  The sys_brk() system cal is provided by the kernel, to allocate memory without the need of moving it later. This call allocates memory right behind application image in memory. This system function al ows you to set the highest available address in the data section.

 

  This system call takes one parameter, which is the highest memory address need to be set. This value is stored in the EBX register.

 

  In case of any error, sys_brk() returns -1 or returns the negative error code itself. The following example demonstrates dynamic memory allocation.

 

  Example:

 

  The following program allocates 16kb of memory using the sys_brk() system call:

 

img202.pngimg203.png