-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory.cpp
More file actions
33 lines (29 loc) · 1.06 KB
/
Copy pathmemory.cpp
File metadata and controls
33 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @file memory.cpp
* @brief Representation of a single memory partition/block in contiguous memory allocation.
*
* CONCEPT:
* In contiguous memory allocation, memory is divided into blocks (partitions).
* Each block maintains:
* - Start Address: The physical memory base location.
* - Size: Total bytes/KB in this block.
* - Allocated Flag: Whether it is currently assigned to a process (Used vs Free).
* - PID: The ID of the process holding this memory block (-1 if free).
*/
#include "memory_manager/memory.h"
Memory::Memory(int startAddress, int size)
: startAddress(startAddress),
size(size),
allocated(false),
pid(-1)
{
}
// Getters
int Memory::getStartAddress() const { return startAddress; }
int Memory::getSize() const { return size; }
bool Memory::getIsAllocated() const { return allocated; }
int Memory::getPid() const { return pid; }
// Setters
void Memory::setIsAllocated(bool allocated) { this->allocated = allocated; }
void Memory::setPid(int pid) { this->pid = pid; }
void Memory::setSize(int size) { this->size = size; }