MUlti-Segment Mode [GDT]
Posted: Sat Jul 15, 2006 11:17 am
Hi, reading the intel manual 5, chapter 3.2.3, i found the Multi-Segment Mode....how can i set the GDT, for th MultiSegment Mode ??
The Place to Start for Operating System Developers
http://f.osdev.org/
Paging is an old way of doing things in the mainframes of the 50s.there is little practical use for this anymore, as paging provides simpler inter-process protection, and newer CPUs support the XD/EP/NX bit
I'm very interested in making such an OS, but do you happen to know which compiler supports this, e.g gcc ??-no compiler will suport this Very Happy (almost)
And what about LDT?be aware of the 8192 llimitation in the GDT this mean that you can only have approx 4000 or so of process running ... do not ask Intel for more
exactly -- however, in a general use OS, it is too inflexable (in a dedicated machine, such as embeded platforms or gaming consoles, where the developer has absolute control over the system, this would be a much better solution)wouldn't this be perfect for dedicated machines like servers or something (with pre-set memory limits for each process?
swapping is achieved for segmentation quite easily, however it is more complicated, and requires much larger portions to be swapped out more frequentlyI'd imagine that swapping is not quite easy to realize without having paging?
GCC is the one that definately wont support it (i believe the intel compiler will (free only for linux), the MS compiler might -- have to do more checking, and watcom definately will -- this is often considered the primary reason to use it)I'm very interested in making such an OS, but do you happen to know which compiler supports this, e.g gcc ??
the LDT cannot store processes, and it is local to each process (each process should have its own LDT), however, this limit is artificial, and easily extended indefinately (even OSs that use segmentation, do not use the GDT in this way) by editing the GDT at runtime -- the GDT will only contain a few entries, the GDT is edited on each task-switch, to add the appropriate entries (which are stored in the process table anyway)And what about LDT?
I would say the later. There is some overhead to paging, but in most cases it is worth it for the benefits, such as easier memory allocation, more granular swapping, and stronger protection mechanisms.matthias wrote:Interessting.. Interesting, wouldn't this be perfect for dedicated machines like servers or something (with pre-set memory limits for each process? Or is this bullshit?
Without paging, you would probably need to swap out an entire task at a time instead of individual pages. This would still be feasible, but it would certainly be less useful.mattias wrote: also I'd imagine that swapping is not quite easy to realize without having paging?). Only thing is, it is hard to realize Especially, the following bit
gcc doesn't. You would probably want one of the DOS compilers.mattias wrote:I'm very interested in making such an OS, but do you happen to know which compiler supports this, e.g gcc ??
Each LDT can also contain 8192 segment descriptors.mattias wrote:And what about LDT?
but the LDT cannot contain processes -- all 8192 segment descriptors must be used for the same process (well... technically they dont have to be, but basically your still left tracking outside the CPU structures, which makes it essentially the same as altering the GDT -- which is easier)
Each LDT can also contain 8192 segment descriptors.
Well, these stuctures are largely whatever you make of them. Certainly, the intention of the LDTs is to allow each process to have its own descriptors, but if the goal is to exceed the 8192 descriptor limit of the GDT, it could be shared between processes. On the other hand, if you have 4000 processes at the same time, you are probably already running more than you should be at a time.JAAman wrote:but the LDT cannot contain processes -- all 8192 segment descriptors must be used for the same process (well... technically they dont have to be, but basically your still left tracking outside the CPU structures, which makes it essentially the same as altering the GDT -- which is easier)
Each LDT can also contain 8192 segment descriptors.
hmmm, true, GDT limit of 4000 processes is enough for most applications of segmentation. Imagine you have:rexlunae wrote:Well, these stuctures are largely whatever you make of them. Certainly, the intention of the LDTs is to allow each process to have its own descriptors, but if the goal is to exceed the 8192 descriptor limit of the GDT, it could be shared between processes. On the other hand, if you have 4000 processes at the same time, you are probably already running more than you should be at a time.JAAman wrote:but the LDT cannot contain processes -- all 8192 segment descriptors must be used for the same process (well... technically they dont have to be, but basically your still left tracking outside the CPU structures, which makes it essentially the same as altering the GDT -- which is easier)
Each LDT can also contain 8192 segment descriptors.
I still aim at 32-bits.bontanu wrote:BTW...
Do not forget that there is NO segmentation in upcoming 64bits architecture
except malloc is part of the application -- you need something to give the memory to malloc (this requires a syscall -- and you definately do not want to make a syscall every time you need to allocate memory), and then there is deallocation -- this cannot be handled properly with a simple segmentation adjustmentThe only thing you need is a function like malloc() to allocate memory
except, there are many more processes than that -- i currently have 24 processes running right now -- and that doesnt include all the system processes (that number is from windows task manager -- which includes some, but not all, OS processes)
64 MB -> OS and IO buffers
64 MB -> ftp server
128 MB -> mail server
256 MB -> webserver
So only (4 * 2) + 1 (null desc) descriptors needed in GDT (in the best situation),
not sure why -- and it is quite easy to do without invlpg completely (in fact, it didnt even exist until the P5) -- it is only needed for invalidating global pages (which are not invalidated on context change) -- though it can improve performance to use it elsewhere as wellnice idea because I don't like paging at all, especially invlpg.
but it does -- malloc only requests full pages from the OS (some OSs will only allocate 4KB, or 4MB, or some other larger number, at a time) -- then malloc will reuse the page for several callsAlso you're not wasting memory space since you don't use pages (ie if you need to allacote only 4 bytes and your allocator doesn't use the rest of the page that has been allocated.
not true -- invlpg usually takes zero time -- the only thing it does, is invalidate any TLBs which currently contain that page (if the page isnt in the TLBs, then it will do absolutely nothing... and if it is in the TLBs, it will not take any extra time over what it would have taken if the entry had not been in the TLB) -- it doesnt load the TLB with any new values, it will only reload the page when the page is accessed -- just as if it hadnt been in the TLB at allWell actually you do of course but not with the cost of updating page tables (invlpg again Twisted Evil )
not as many as you assume -- you seam to missunderstand many things about pagingThis has great advantages. But is it worth the effort? I mean, will it be hard to program?