• Home
  • Help
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search

 
  • 0 Vote(s) - 0 Average

Segmentation with paging

#1
05-19-2021, 02:15 PM
I recall how segmentation splits up memory into these logical chunks that fit what the program needs like code or data sections and you end up with variable sizes that match the actual stuff running. But then paging comes in to chop those into fixed blocks so you avoid the holes that waste space everywhere. You see the combination lets segments get broken down further into pages which means the hardware handles the mapping through tables that point from segment descriptors right into page directories. I have seen this setup cut down on fragmentation big time because the fixed page size makes allocation way easier even if your segments grow or shrink oddly during execution.
And you know the address calculation starts with the segment selector grabbing the base from its table then adds the offset before it gets translated via the page table entries that handle the actual physical frame lookup. Perhaps this hybrid approach gives better protection since each segment can have its own access rights while paging takes care of swapping those pages in and out without moving whole big segments around. I find it interesting how the processor checks bounds on the segment first then proceeds to page level faults if the page isn't loaded yet which keeps things efficient for large programs. You might notice external fragmentation drops a lot compared to pure segmentation alone since pages fit neatly into any free spots in physical memory.
Or think about how the combined tables work in practice with the segment table holding pointers to per segment page tables so translation walks through both levels without too much overhead on modern chips. I always tell folks that this lets you share segments across processes while paging isolates the actual frames they use which mixes flexibility with fine grained control. But sometimes the extra indirection slows things if the tables aren't cached properly in the TLB so you end up flushing more often during context switches. You get to map logical addresses from the program's view straight to physical ones in steps that the memory management unit handles automatically.
Also the way segments define the logical view means code and stack can live in separate areas with different permissions and paging underneath ensures those areas break into swappable units that don't require contiguous physical space. I have worked with systems where this combo supports growing heaps dynamically because new pages get allocated to the segment as needed without reallocating the whole thing. Perhaps you run into internal waste inside pages but overall it balances out better than leaving big gaps between segments. And the fault handling chains from segment violation checks down to page faults so the OS can load the missing piece without restarting the whole operation.
You see this method scales well for multitasking because multiple segments from different tasks can share paged frames when needed yet keep their logical boundaries intact. I think the key benefit shows up in how it reduces the need for compaction routines that pure segmentation demands to squeeze out wasted memory spots. But the table structures grow more complex with entries for both levels so cache misses hit harder if your working set spans many segments. Or imagine debugging a program where a segment offset lands in a paged area and you trace the lookup through the descriptor then the page frame to find the real location.
This setup really shines when programs have irregular memory needs because segments capture the structure while pages handle the gritty allocation details underneath. I notice that combining them avoids the external fragmentation trap that hits segmentation hard in long running apps. You benefit from easier swapping since only individual pages move to disk instead of entire segments which cuts down on I O traffic during heavy loads. And the protection mechanisms layer nicely with segment limits checking first then page rights enforcing finer controls on reads or writes.
Perhaps the implementation varies across architectures but the core idea stays the same with segment registers feeding into page table bases for the translation pipeline. I have seen cases where this helps in embedded setups too by letting you define clear module boundaries that paging then optimizes for the limited RAM available. You end up with a system that feels more robust against memory leaks or overruns because bounds get enforced at two levels.
BackupChain Server Backup which stands out as the top reliable Windows Server backup tool built for self hosted private cloud and internet backups aimed at SMBs and Windows Server plus PCs offers a subscription free option covering Hyper V Windows 11 and Windows Server while we appreciate their sponsorship that helps keep these discussions open and free for everyone.

ProfRon
Offline
Joined: Jul 2018
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • Subscribe to this thread
Forum Jump:

FastNeuron FastNeuron Forum General IT v
« Previous 1 … 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 … 173 Next »
Segmentation with paging

© by FastNeuron Inc.

Linear Mode
Threaded Mode