0% found this document useful (0 votes)
44 views

Memory Segment Block: Designed and Developed by - VIVEK BURUGALE (1964114)

This document provides a guide for allocating memory using segmentation. It involves the following key steps: 1. Read process data from a file and store characters in a linked list, then separate integer values into another linked list. 2. Start memory allocation using segmentation. Loop through the integer linked list, allocating memory blocks of size P->size or the max segment size if it is smaller. Track the total allocated size. 3. If the total allocated size exceeds the max memory size, break out of the loop. Otherwise, continue allocating blocks until the entire integer linked list is processed.

Uploaded by

VivekBurungale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Memory Segment Block: Designed and Developed by - VIVEK BURUGALE (1964114)

This document provides a guide for allocating memory using segmentation. It involves the following key steps: 1. Read process data from a file and store characters in a linked list, then separate integer values into another linked list. 2. Start memory allocation using segmentation. Loop through the integer linked list, allocating memory blocks of size P->size or the max segment size if it is smaller. Track the total allocated size. 3. If the total allocated size exceeds the max memory size, break out of the loop. Otherwise, continue allocating blocks until the entire integer linked list is processed.

Uploaded by

VivekBurungale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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++;

You might also like