MEMORY ALLOCATION USING SEGMENTATION
Main GUIDE - PROF SHEETAL JADAV
Designed and Developed By - VIVEK BURUGALE (1964114)
DATE : 2 APR 2020
Allocate
Memory Process Text
Open the File
Segmentation File
1.0
read each character
from the file
readData = getc(fp);
getProcessData
1.1
loop True Insert each character
value to Link List
readData != EOF
(char list)
Create new False
List _PROCINTNODE INTNODELIST
from INTNode List
Close the File
remove extra spaces
delete node whose from the Link List
contain 0 value in (char list)
_PROCINTNODE list
separate Integer data
values & store in
separate Link List
(int list)
Start Memory
_PROCINTNODE
Allocation using
&
Segmentation
_MEMSEGMENTBLOCKS
2.0
delete linked list Return
Success
(char list) INTNODELIST
P=PROCINTNODE typedef struct
__memsegmentblocks{
struct
__memsegmentblocks *next; //structure to store integer
bool isfree; data
size_t size; typedef struct __procintnode
Loop void *memoryaddress; {
typedef struct __s_block{
P!=NULL }_MEMSEGMENTBLOCKS; int process;
struct __s_block *next;
Total Size = 0 int size;
struct __s_block *prev;
struct __procintnode *next;
bool isfree;
MEMORY }_PROCINTNODE;
FALSE size_t size;
SEGMENT BLOCK }_SBLOCK;
True
PROCINTNODE
Break SRBK BLOCK
TRUE IF TRUE
IF
Total Size +
P->SIZE <= M LEGENDS
P->size <=MM
P = PROCINTNODE
FALSE M = MAX_SEGMENT_SIZE (256KB)
MM = MAX_MEM_SIZE (1024 * 1024)
Total Size = 0
IF FALSE FALSE
Total Size 0; start_address =
Total Size + M
Break sbrk(0) + 1
<=MM
allocate next memory block
start_address = for Segmentation
sbrk(0) + 1 of P->size + 1 Size
ON memSegBlockshead
allocate next memory block
for Segmentation
of M Size *end_address =
ON memSegBlockshead sbrk(0);
*end_address =
sbrk(0); total_size += P->size;
print
total_size += M; Process, start_address,
end_address,
segmentnumber
print
Process, start_address,
end_address, P->size =0;
segmentnumber P = P->next;
segmentnumber++;
P->size = P-size - M;
segmentnumber++;