OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Jun 26, 2019 2:01 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: What features can I rely on the existence of across arch
PostPosted: Fri Feb 03, 2017 2:32 am 
Offline
Member
Member

Joined: Wed Mar 09, 2011 3:55 am
Posts: 296
zesterer wrote:
Can I rely on the existence of:

- IRQs?


On any reasonable modern processor you can rely on the existence of some sort of interrupt mechanism.

You cannot rely on any particular implementation of this mechanism being present. Each processor does things its own way.

Quote:
- Paging?


On any modern processor intended for mobile, desktop, or server use you can rely on the existence of some sort of paging mechanism. You will also find paging on many, but not all, embedded processors. Unless you're developing an OS for embedded use, you should probably refuse to support processors that don't have paging, as it has significant benefits for reliability, security, and debugability, and non-embedded processors that don't have paging are going to be in very old, low-spec hardware.

That said, most (all?) processors will *not* have paging active at boot, so your early boot code will have to deal with a non-paged environment (unless you outsource that to an external bootloader), but early-boot code will tend to be architecture-specific anyway.

You cannot rely on any particular implementation of paging being present. Address space size, number of paging levels, and page size may all vary.

Quote:
- Segmentation?


The only processor that you're likely to encounter with segmentation is an Intel processor. Every modern operating system for Intel processors just uses it in real mode at boot time, then, when switching to protected/long mode, sets up the minimum in terms of segmentation that is needed to run as if the segmentation system didn't exist, and then promptly forgets about segmentation. In long mode and compatibility mode, segementation only exists for historical reasons and you can't do anything with it other than setting up a flat address space and forgetting about segmentation. The only reason you would ever use segmentation on an Intel processor is if you're running in real mode or 16-bit protected mode for some reason.

Quote:
- A serial I/O device?


That depends what you mean by "a serial I/O device". If you mean "an RS-232 device", no.

Quote:
- Multiboot-compliance bootloaders?


No, multiboot is entirely a software thing. It's also mostly an x86 thing. It could conceivably be adapted to non-x86 systems, but you're not even guaranteed to see it on x86 systems. In fact, any x86 system that ships with a proprietary OS (which is to say, Windows), will almost certainly *not* have a multiboot compliant bootloader unless the user puts it there. That said, if the user has installed Linux, there almost certainly will be a multiboot compliant bootloader (though, depending on how the user has things set up, it may not be the first bootloader to run), and if someone is trying out alternative OSes, they're likely to try out Linux before they try out your OS, so even though the general rule is "no, you cannot count on a multi-boot compliant bootloader", you probably can count on the people that are likely to try your OS having one (on x86).


Top
 Profile  
 
 Post subject: Re: What features can I rely on the existence of across arch
PostPosted: Fri Feb 03, 2017 7:01 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 2204
Yeah, thinking in terms of "how many architectures can I support" is all wrong. Portability always sacrifices speed and the ability to exploit specific features of a CPU. That might be ok if you want something that is mediocre on many CPUs, but not otherwise. I only support x86 because only x86 has segmentation, which I consider a vital component of memory protection. I also rely heavily on assembler code instead of C, which I can do since I only support x86.


Top
 Profile  
 
 Post subject: Re: What features can I rely on the existence of across arch
PostPosted: Fri Feb 03, 2017 10:08 am 
Online
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 583
rdos wrote:
Yeah, thinking in terms of "how many architectures can I support" is all wrong. Portability always sacrifices speed and the ability to exploit specific features of a CPU. That might be ok if you want something that is mediocre on many CPUs, but not otherwise. I only support x86 because only x86 has segmentation, which I consider a vital component of memory protection. I also rely heavily on assembler code instead of C, which I can do since I only support x86.

x86_64 does not support segmentation. You're basically saying "Rather than designing my kernel so that it can adapt to different scenarios I optimize for an architecture that have been obsolete for at least 10 years and today only serves a niche market".

I also really doubt the "portability hurts performance" statement. Supporting a feature on one architecture does not mean that you have to require it on every architecture. However it is very easy to convince me if that statement is indeed true: Just show me a single (general purpose) OS that exploits all the nice special features of x86 and outperforms Linux or Windows on common workloads (or even a single real-world workload; microbenchmarks don't count). Hint: You can't; performance depends on the design of your algorithms and not on "Let me use segmentation instead of paging".

_________________
managarm: A microkernel-based OS that is capable of running a Wayland desktop


Top
 Profile  
 
 Post subject: Re: What features can I rely on the existence of across arch
PostPosted: Fri Feb 03, 2017 10:54 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1456
Location: Athens, GA, USA
I have created a new thread if you wish to continue this discussion without derailing this one.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
μή εἶναι βασιλικήν ἀτραπόν ἐπί γεωμετρίαν
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Crupette and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group