flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Building a memory bitmap for 64bit Goto page 1, 2 Next |
Author |
|
edfed 09 Dec 2008, 17:05
just do it for 32 bits.
i predict the first retro evolution. intel will use IA64 as a little extension, making a 32bits µP able to compute 64bits operands. the address bus will be 32 bits wide, and operands will be 8, 16, 32 & 64. all the code for native IA 64 long mode will be obsolete. all native IA64 µP will be abandonned, what a better arch than IA32? |
|||
09 Dec 2008, 17:05 |
|
bogdanontanu 09 Dec 2008, 17:14
Quote:
No it is not! |
|||
09 Dec 2008, 17:14 |
|
calpol2004 09 Dec 2008, 17:18
bogdanontanu wrote:
How then? This is just a simple easy way of making a simple memory manager for a kernel. Maintain a bitmap of physical 4kb blocks. Whenever you need memory then the memory manager maps a sequence of those blocks to virtual pages and return the pointer to the first. Some OS's often use structures with extra information as opposed to a single bit. Same principle really. How else could it be done? blurting out "NO!" is pretty dumb IMO if your not going to tell me why I'm wrong. I think i am just going to go for the highest amount of memory BIOS interrupt 0x15 will give me. Not sure if int 0x15 will work though, it may only give me regions below 4GB, i haven't heard of any 64bit equivalents so i assume it will. |
|||
09 Dec 2008, 17:18 |
|
Octavio 09 Dec 2008, 18:07
usually there is free physical memory only when the system boots ,later all the memory is used for aplications of for the disk cache. A simple method is to use linked lists with the available pages.
|
|||
09 Dec 2008, 18:07 |
|
baldr 09 Dec 2008, 19:07
calpol2004,
When in doubt, RTFM. x86-32 can easily address 64 GiBs (36-bit addressing with PAE/PSE-36), x86-64 extends that up to 52 bits (though early CPUs was restricted to 40-bit addressing, for later you must use CPUID to check MAXPHYADDR, maximum physical address width). Int 15/E820 should be considered with caution. QWORDs for base/length are long enough; you may also examine MTRRs do differentiate that ranges further. Do you think it's only RAM in physical address space? |
|||
09 Dec 2008, 19:07 |
|
baldr 09 Dec 2008, 19:10
edfed,
They already do 64/128 bits (MMX/SSE) |
|||
09 Dec 2008, 19:10 |
|
f0dder 09 Dec 2008, 19:33
You will have to deal with "holes" - remember memory mapped devices.
I dunno what the most efficient method of managing memory is, but filesystems are moving away from free-sector bitmaps and towards "extents" - might be worth considering. |
|||
09 Dec 2008, 19:33 |
|
baldr 09 Dec 2008, 19:51
f0dder,
It's direct-mapping vs. list-traversing issue… Not an easy choice without content-addressable (associative) memory. |
|||
09 Dec 2008, 19:51 |
|
edfed 09 Dec 2008, 19:54
i know that, but speak about an extenssion with general purpose registers.
i like a lot this al, ah, eax, ebx, edi, esi representation my ideal µP for now have this: al,ah,a2,a3,a4,a5,a6,a7 ax,ay,az,aw eax,fax rax idem for ebx,ecx,edx and new registers rex,rfx,rgx,rhx,rix,rjx.. up to 16 64bits registers for general purpose. index registers: rsi, rdi cutted like rax and 16 index registers in total rai, rbi, rci, rdi, rei, rfi... segement registers..? what for? ok, just because it is usefull, but will be named base registers, and be 32 bits. ecs= base address of code eds= base address of data ees, efs, egs, ehs, eis, ejs, eks, els... up to 32 registers it is a dual core µP of course ( cause it is fun.) the µP will integrate 4Gb of ramonchip. the pinout will only be for I/O data & address lines, and some very fast communication peripheral it will send video signal with a vga output pins., up to 1280*1024 32bpp no need of SSE or any FPU. i don't care, i just want ot code in asm. and connect it to my electronics for fun. to know th eoccupation of memory, there is a way. a file system in the ram, about the ram |
|||
09 Dec 2008, 19:54 |
|
f0dder 09 Dec 2008, 20:11
edfed: perhaps you meant to post that in this thread?
|
|||
09 Dec 2008, 20:11 |
|
baldr 09 Dec 2008, 20:26
edfed,
How about big bit pool with means to address any portion of it, instead of registers? Well, almost any (regarding ALU size limits). [31…0], [39…32] instead of eax, cl? Shifts will be (almost) free. Segment/base registers? Addressing modes should be revamped thoroughly to make some use of that, position-independent code (did I said I love PDP-11? ) Multiple cores with integrated memory controller. Cache consistency/memory contention should not be an issue, at least on-chip. VGA 15-pin D-SUB? HDMI or DisplayPort. SSE? Why not. FPU? Definitely. File system in RAM is the VAS descriptors' description. |
|||
09 Dec 2008, 20:26 |
|
neville 09 Dec 2008, 20:51
I don't like the memory bitmap idea because it is the same concept as "file allocation tables" on disks - can lead to fragmentation, performance degradation and the need for defrag.
Much better for the kernel to maintain a Master Memory Contents Database for all processes, and ensure all processes have contiguous memory allocated. The maximum database size can be based on a proportion of available physical memory. 1/128 (~1%) or 1/256 (~0.5%) is about right for FAMOS. calpol2004, currently X86-64 is limited to 52-bit address bus. edfed, I like your 8/16/32/64 bit register definitions but it would make the instruction set too big and complex to implement it? Better to add just a few extra "bit-slice" instructions to the instruction set to achieve almost the same result? _________________ FAMOS - the first memory operating system |
|||
09 Dec 2008, 20:51 |
|
baldr 09 Dec 2008, 21:21
neville,
What is the problem with fragmentation in memory? You don't have to perform costly seeks and wait for plates to rotate in place to read required sector… Contiguous memory for processes? Let's see… You have 50% memory load (and uptime is long) and try to allocate 20% of memory. How do you think, probability to have that much contiguous memory will be more than 0.1? |
|||
09 Dec 2008, 21:21 |
|
neville 09 Dec 2008, 22:11
baldr,
Of course memory fragmentation is much less performance degradation than disk fragmentation in a VM OS. But it is still undesirable. As you have implied yourself - if uptime is long the worse the fragmentation will be! A good OS should run FOREVER with no change in performance, no matter how "busy" it is sometimes. With memory fragmentation, sooner or later it will be necessary to defrag. Otherwise all available memory will be in e.g. 4K chunks when uptime is very long. So better to "defrag" sooner - at memory allocation time!!! So contigous memory is always allocated initially to the process or data. Actually in practice it is worthwile to allow running processes to grab maybe ONE extra (usually non-contiguous) block of RAM, but "memory bitmaps" are not needed for that! _________________ FAMOS - the first memory operating system |
|||
09 Dec 2008, 22:11 |
|
f0dder 09 Dec 2008, 22:18
neville: with paging and per-process address space, you don't need any kind of "defragmentation".
Is it a problem having the physical memory fragmented in 4kb chunks? Processor cache lines are much smaller than that. |
|||
09 Dec 2008, 22:18 |
|
LocoDelAssembly 09 Dec 2008, 22:54
Quote:
May cache line associativity be affected by fragmented memory? |
|||
09 Dec 2008, 22:54 |
|
neville 10 Dec 2008, 00:12
f0dder wrote: neville: with paging and per-process address space, you don't need any kind of "defragmentation". What software mechanisms, if any, are available to control and optimise how the CPU manages its caches? IMO unless EVERYTHING else is fully optimised first it won't make any difference, so who cares? Do you suggest paging the cache too? With paging and per-process address space you can have pseudo-contiguous logical memory, but it just disguises the actual fragmented physical memory. At the end of the day the CPU has to access physical memory! So IMO yes, it is a problem. And bit-mapping paged memory is even worse than bit-mapping physical memory. How big or small should the pages be? 2MB ? 4kB? If you implement paging there are arguments for both, similar to cluster size on disks. Generally the bigger the whole, the bigger the chunk (page, cluster etc) for best "efficiency". But in truth it depends on the nature of the data, which the allocation process has no knowledge of. So the best size is 0. Non-existent! _________________ FAMOS - the first memory operating system |
|||
10 Dec 2008, 00:12 |
|
f0dder 10 Dec 2008, 01:11
neville: as discussed in this thread, not having a paging mechanism poses a lot of problems... like getting your memory fragmented. Allocating big fixed chunks at application startup isn't really a viable solution for typical real-world applications...
Yes, a CPU has to access physical memory, but can you feel a speed difference (on current, real-world x86 hardware) between accessing (physical) pages that are scattered all over RAM vs. physical pages that are allocated contiguously? On x86, I believe paging is the best solution that's possible, unless we want to go back to win16 style movable memory blocks and lock/unlock-to-get-pointer. And designing an alternative to paging, for a theoretical CPU, is non-trivial. |
|||
10 Dec 2008, 01:11 |
|
bitRAKE 10 Dec 2008, 02:18
A combination of bitmap and linked lists should be used; or a multi-staged bitmap. Say pages are 4kB that is 32kbits - if each bit specifies a 4kB page then each page of memory has flags for 128MB of memory - these pages don't really need to exist unless another bit (higher level bit table) indicates a need to map it. One 4kB page maps 4096GB - if each bit represents 128MB! ...and so on, one 4kB page maps 131072TB - if each bit represents 4TB! etc...
1TB = 2^40, therefore no more than three levels are needed. What are the minimum instructions to access these three levels? bt [rsi],eax jnc @F bt [rsi],ebx jnc @F bt [rsi],ecx jnc @F Paging should be used unless someone is designing a console type OS. |
|||
10 Dec 2008, 02:18 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.