Jump to content

Operating System Library

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
15 replies to this topic

#1
brade8000

brade8000

    Newbie

  • Members
  • PipPip
  • 21 posts
Hello again,
In my last thread someone told me to make my own librarys for my operating system.
My question is how do i make my own C++ librarys.
Thanks.:cool:

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You can look at the source code for GCC to get some ideas.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
I'd say start with writing the C library, as it's basic and you can build on top of it to make your C++ library. When I started working on my own OS, I looked up the C library functions at cplusplus.com's library reference, read the specifications, and figured out how to write them. Since I've done this sort of thing before I can help you out should you need it.
sudo rm -rf /

#4
brade8000

brade8000

    Newbie

  • Members
  • PipPip
  • 21 posts
Awesome I need some help as my first OS

#5
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
What do you need? More importantly, what features do you want your OS to have?
sudo rm -rf /

#6
brade8000

brade8000

    Newbie

  • Members
  • PipPip
  • 21 posts
I want the user to be able to write text filesand some more basic stuff mainly i just want it to run

#7
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
Ok, that's not too bad. You're going to have to plan this out very carefully before you write a single line of code. Here are a few things to consider:


  • Are you going to allow more than one program to run at a time? (multiprocessing) If so, you're going to have to write your own thread scheduling subroutines, context switching...just don't do it. Like really. Don't.
  • Are you going to allow user programs to run, or is everything part of the operating system? (If you write everything then it makes your life much easier but isn't as fun.)
  • What processor are you targeting? (I can only help you with Intel, or MIPS to a lesser degree.)
  • If you're targeting an Intel processor, what mode are you going to be executing in? (See here for a brief description of x86 processor modes.) Most modern operating systems use protected mode. However, you can go one of three ways:
    • Protected mode:
      • Each program runs in its own address space, so it can't touch other programs. Or your operating system.
      • Each program also runs at one of four privilege levels. Thus you can prevent specific user mode programs from doing certain things, while allowing others with higher privileges to do those same things.
      • Downside - you're probably going to have to implement paging. This is not fun.
      • No BIOS routines. It's a crutch, but it's slow and somewhat limited. No modern operating system that I know of uses it.

    • Virtual 8086 mode: I don't recommend this as you're making a basic operating system and this won't be of much use to you.
    • Unreal mode: This basically lets you use all the RAM you want and allows you to use the BIOS routines. The BIOS is slow - even slower than Windows, if you can believe that - but using it as a crutch also means that you're not going to have to create your own file system drivers just to create a simple fopen(). It doesn't do well with large disks or large amounts of memory, but for something as simple as I think you want this it's all right. Learning experience.

  • Are you going to have a rudimentary GUI or a pure command-line interface? The GUI isn't too bad, I've written a basic one in assembly language. Don't remember where I put the code...
  • Are you going to allow a mouse? It doesn't have to have a pointer; your driver can just move the console cursor around.
  • Speakers? Using the motherboard speaker to beep at the user when they do something stupid is pretty easy.
  • Memory management system, for stuff like malloc()? Oooh, this'll be fun.
These are all the questions I have for now, but I know I'll have more. Sit down, plan out what features you want, think of how you'd write them in C or basic C++, and see what library functions you're going to need. Figure out your answers to the above questions, come up with your own, and we'll work from there. Sound good?
sudo rm -rf /

#8
brade8000

brade8000

    Newbie

  • Members
  • PipPip
  • 21 posts
OK kool thanks.

#9
brade8000

brade8000

    Newbie

  • Members
  • PipPip
  • 21 posts
No I don't want multiprocessing.
It will all be on the OS.
Whatever processer is best and easiest.
I will have GUI.
I will allow mouse.
Speakers Yes.
Memery Yes.
Want to be able to write .txt files and run smoothly.
Thanks.
P.S. I have dicided to use Dev C++ is that a good language to use for an OS.

#10
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 297 posts
Well most Computer Desktops are Intel Core Two Duo's running at 2.53GHz

So you can't just say what's the easiest because there are different ones!

Start Menu>My Computer>System Tasks>System Information. (If your running Windows XP) :)

#11
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
The processor model doesn't matter, it's the processor family. By the way, brade8000, I saw your questions about what kernels are...you're a looong way off from writing an OS, buddy.
Dev C++ is not going to get you far, nor will any sort of C++. You can't use any standard library functions, so no iostream, no std::string, and so on. Only difference between C and C++ at this low of a level is the ability to use classes. That's it.

As far as your GUI and mouse, if you don't know what a kernel is, you're not going to be able to write a device driver for either. I strongly suggest you read some books on operating systems first. If you start coding now you're going to get frustrated and give up.
sudo rm -rf /

#12
brade8000

brade8000

    Newbie

  • Members
  • PipPip
  • 21 posts
Ok i will use intel