Skip to main content

Posts

Showing posts with the label Memory Management

C Program to show an example of Memory Management

  C Program to show an example of Memory Management # include <fcntl.h> # include <sys/types.h> # include <stdio.h> # include <unistd.h> # include <sys/resource.h> void main ( void ) { printf ( "\n The current location of the program break: %d\n" , ( int ) sbrk ( 0 ) ) ; int * t = sbrk ( 200 ) ; printf ( "\n After incrementing program's data space by 200 bytes using sbrk() system call" ) ; printf ( "\n The current location of program break: %d\n" , ( int ) sbrk ( 0 ) ) ; printf ( "\n Setting the end of data segment using brk() system call" ) ; brk ( t ) ; printf ( "\n The current location of the program break:%d\n" , ( int ) sbrk ( 0 ) ) ; }