-1

I'm not sure if this is the right spot to put this. I was wondering how would you create and operating system like linux or windows or novell. What programs would you use. I've always wondered how it was done. I would love to learn to create my own.

24
Contributors
40
Replies
47
Views
13 Years
Discussion Span
Last Post by davidkeeler63
0

I'm not sure if this is the right spot to put this. I was wondering how would you create and operating system like linux or windows or novell. What programs would you use. I've always wondered how it was done. I would love to learn to create my own.

To achieve this you would need to program in a low-level language such as ASM (usually), but hey this is a C++ forum so I'll explain how to do it in C++.

It is essential to understand the heart of the OS, which is called the kernal, is the MOST important part of an OS. Fancy graphics and SVGA coding can all come after you have developed a solid hardcore kernal. Now as for what programs you would use, believe it or not you can use any standard command line compiler or IDE (such as Borland or MSVC++). The most important thing about using an OS is how its loaded. All hardrives and bootable media have something called boot sectors (typcal near front cylinders of the media) that allow "execution" of your OS. As long as you comply with specific system standards and handle all your RAM right then your OS should be properly loaded. Making an OS is a in-depth subject, when I first took a shot at it the below tutorials really helped me out. Check it out.

Tutorial on making a C/C++ OS:

Part 1:
http://www.1cplusplusstreet.com/vb/scripts/ShowCode.asp?txtCodeId=6718&lngWId=3

Part 2:
http://www.1cplusplusstreet.com/vb/scripts/ShowCode.asp?txtCodeId=6743&lngWId=3

0

This was originally posted in the tutorials section of the site. It got moved to C++. I think Computer Science is more appropriate for it so it's being moved once again ;)

0

Sorry if I'm being in any way rude by this, but do you understand the undertaking you would have to go through in creating an OS? Bill Gates has a little empire for a reason. The OS would have to be adaptable to modern security risks and have the ability to adapt to software designers specifications.

I admire your desire to build one, but understand it is quite the task.

0

he can try to build a kernal, thats what counts, and proven by linux a kernal can be a one man job, who knows maybe he will make an awsome kernal and distribute the source and in 4 years it will be graphical...

but in the rare occerence of the stated situation above, the most important thing is by trying to develop an OS he will understand the guts of how an OS works. Good Luck, despite an OS being a huge task and a duanting procedure, you can still keep it small and practial, creating nessisary OS's to repair computer complications would be a good application.

EDIT: remember an OS is just a system level environment, hello world can be an OS if developed and installed correctly.

0

the linux kernel was a one man job 13 years ago... with all due respect to Torvalds (and the man deserves a lot of it), I doubt he would be able to write the gargantuan beast we have now, all on his own

well, he probably could, but it would be more complicated now by orders of magnitude than what it was before...

but yes, you're of course right. viperman224 can write a basic dos. its quite an undertaking though...

I would recommend doing a LFS install first, so that you see how an OS these days fits together (as good as an article could be, nothing beats experience). better to see what end result you want than to start writing c without a clear image of what you want as a goal

or maybe a LFS of an older kernel would be better...they would be simpler without all the extra security and networking routines. you can always learn about those later...the important bit is to understand how dos works :)

but yeah. an interest in doing something is the first step towards much fun (and long nights...and an annoyed girlfriend...)

0

The most obvious implementation is to write a cooperative multitasking system whereby when one application has finished doing stuff with the CPU, it calls some kind of yield function, or calls a wait for message function.

In the implementation of that you then have to switch to another task if necessary - possibly by calling setjmp() and longjmp() to save the stack and the cpu context (Assuming this is in C)

Otherwise you'll have to switch stack and save the CPU context manually, which will be CPU specific and may involve assembly language.

Once you've figured out which process needs to run you can then call longjmp() back to the context of that process, and continue it from where it left off. ect.....


On the other hand I would not suggest a DOS ......It sounds like a fun project, but it seems to me that people doing these kinds of projects are building desktop environments/GUI's not an operating systems. With that said, if I may make a suggestion, try using a MACH base rather than a DOS base. Remember the whole system is limited by the functionality of the kernel, plus MACH will just make a lot of things much easier on account of it's messaging system being, well actually existing. ;) This will enable you to not only easily develop software for it, but also to easily extend its functionality.
Make any sense?

0

can you create an os by using visual basic 6...? its all i've got....

I don't think you could do it with VB 6.

I don't think it has the neccesary access to the low-level functions that are required to build an operating system. If it had those, you'd need to compile the code to make it work.

From what I've seen, it's best to do the kernel and base progs in C and ASM, and then to do the base GUI stuff in C++. From there, use whatever else you want to do the rest.

0

Hi,

No, cannot use VB, as it is an interpreted language, meaning it needs libraries (Microsoft ones) to link into the program to complete the coding.

You could, using VB6, write a small virtual environment that might have some process control and that sort of thing. Ugly.

Best bet is C or C++. But then, you need to design a file system in order to get that kernel working. It is an undertaking!

Enjoy.

Christian

0

Hi,

No, cannot use VB, as it is an interpreted language, meaning it needs libraries (Microsoft ones) to link into the program to complete the coding.

You could, using VB6, write a small virtual environment that might have some process control and that sort of thing. Ugly.

Which, I'd imagine, you'd have to write in C or asm.

I dunno... that's kind of interesting, if you think about it-- an interpreted OS! Imagine, a system whose entire userland was comprised of interpreted scripts-- say, Python, for instance. The kernel could be a modified interpreter, which provided all of the I/O functions and process control, in addition to interpreting all of the scripts.

...I dunno... Think that'd be as slow as a dog, though?

0

Try 'EasyOS' to get started.. it comes with all you need.
However remember that you should try making your own version of DOS before you even think of trying to remake Windows...

0

Which, I'd imagine, you'd have to write in C or asm.

I dunno... that's kind of interesting, if you think about it-- an interpreted OS! Imagine, a system whose entire userland was comprised of interpreted scripts-- say, Python, for instance. The kernel could be a modified interpreter, which provided all of the I/O functions and process control, in addition to interpreting all of the scripts.

...I dunno... Think that'd be as slow as a dog, though?

i read in a MSDN blog about a C#.NET based system.

0

i read in a MSDN blog about a C#.NET based system.

Probably similar to Sun's approach wherein they had a small bootloader (written in C, IIRC) which would load the JRE and then treat the JRE as the OS

0

Just to clear something up that I saw earlier in the thread. Linux was not a one man job and was not built from scratch. Linus created the original Intel 386 Linux kernel based on MINIX a simple unix like OS created by A. Tanenbaum, a computer science professor. MINIX was created to teach OS design and implementation. It was important to Tanenbaum that MINIX didn't get too complex. Otherwise, it would cease to be of use as a learning aid. Linus (and many others) wanted a more fully featured OS that wasn't proprietary. In those early days the whole hacker community was based around the free movement of un-licensed code (what we now call open source) being borrowed and tinkered with like neighbours borrow cups of sugar. Things were changing though, and proprietary code was starting to become the new way of things. That's when Richard Stallman saw red and started the Free Software Foundation. Linus was affected by Richard's movement and decided to release his work freely.

It was the sheer number of geographically challenged hackers, with just the internet to connect them that managed to create an OS (Linux.) Where before the traditional ethos was to have a carefully managed project team where design decision were tightly controlled. The Free Software Foundation and their GNU project attempted an OS (HURD) in the traditional manor. It just never got of the ground. In contrast a global, barely managed community, initiated by Linus Torvalds produced Linux seemingly by magic. It was a revolution. Read 'The Cathedral and The Bazaar' for the whole story.

0

I'm not sure if this is the right spot to put this. I was wondering how would you create and operating system like linux or windows or novell. What programs would you use. I've always wondered how it was done. I would love to learn to create my own.

Hmmm. Tall order. :)

At the most basic level, an operating system is nothing more than a program than:

  • initializes the hardware
  • provides a means to run programs, and
  • provides orderly access to the hardware from the program

The intent of an OS is to obviate the need to write (or include) all the hardware access code for each new program written.

DEC's RT-11 is an example of a simple OS that allows the programmer to access the hardware using an orderly application programming interface (API). MSDOS/PCDOS/etc. is another example of the lowest level OS.

Imagine you are sitting in front of a DEC PDP-11 replete with front panel toggle switches. Using those switches, you could enter an entire program into the computer, then run the program. This would be fine for a simple program the first 5-10 times. But when you move on to more complex programs, you'd want an easier way to prepare programs and to run them.

So perhaps you would write a program that

  • initializes the hardware to some known state,
  • provides access to a persistent storage medium (paper tape, mag tape, disk drive, et al), and
  • provides you with a user interface on a dumb ASCII terminal that lets you
    • edit/create a human-readable program in some assembly language
    • run an assembler to translate a human-readable file into binary computer-readable data in memory, and
    • run the program

Perhaps you would partition memory into 5 areas:

  • OS,
  • editor
  • assembler,
  • source program, and
  • binary program. When you want to edit, the OS calls the editor as a subroutine, where you can read the source program (from a variety of media perhaps) into the 'source program' memory, change it and possibly save it back to some medium. Upon exiting the editor, you return to the OS' standard user interface. You then tell the OS to run the assembler, which reads the source file in the source program memory partition; it chokes on the unusual syntax you provided it. Back to the editor to fix the source. Back to the assembler to translate it. Then, back at the OS interface again, you tell the OS to run the binary program that now resides in the binary program memory area. Of course, your program causes the computer to halt, and you then have to reload the OS from some medium, reload your program from some medium, make all the changes all over again because you didn't save the last session to some medium.

    To write this OS-like program, you would need all the specifications of the hardware that you intend to use so you can initialize the hardware and provide subroutines for your program to use to access and control the hardware.

    I trust that, by now, a picture is starting to form. What I've described is basically what happened from the late 50's to the late 70's. It was, in essence, a long human bootstrap process, when people figured out how to do all this, because it had never been done before. Find some history stories detailing the days of the IBM 360, the Univac, Sammy Spectra and DEC. Read about how the earliest OSs were developed. Read about TOPS-10 (DEC), Multics, ITS (Incompatible Timesharing System), TENEX, and other early OSs. If you really want to, you can find the source code to some of these OSs online.

0

I'm not sure if this is the right spot to put this. I was wondering how would you create and operating system like linux or windows or novell. What programs would you use. I've always wondered how it was done. I would love to learn to create my own.

You won't spend long in the world of hobby operating systems before hearing the name Bochs repeatedly mentioned. For all I know it might also be used in the development of commercial operating systems. Bochs is a program which simulates a PC in software, and although there are other programs of the type around (such as Microsoft's Virtual PC) Bochs seems particularly well suited to OS development. Its primary function is to allow the testing of an operating system to be done largely in a program which is pretending to be a PC, although it does also need to be tested out on a real PC from time to time.

You will also need a decent compiler. The languages used are most commonly assembler and C. The former you have got to know. Although the latter can be used for most of the coding, there is no escaping the fact that the job of an OS is to manage the hardware; so you have to get your hands dirty with assembly language doing precisely that. The entire OS can be written in assembly language if you want; although most go for C, and a few for C++.

You will also need a versatile linker. If you are developing under Linux you will probably want to use LD. I develop under Windows, and at the moment I am using the Watcom linker. Integrated Development Environments are designed with the idea in mind that you will be developing application programs. In OS work you will probably be using a text editor and a command line compiler most of the time.

0

Ive been at it a few months and have written tyhe beginnings of an O/S (not an OS yet as it doesnt do the functions an O/S is designed to do by definition)

Currently it boots up from floppy using a simple ASM bootloader and it accepts character input from thet keyboard into a buffer, where it is then written to the screen. You can delete and start new lines.

0

they do that with solaris?

i thaught solaris ran UNIX?

No, apparently they do that with a version of their Java Runtime Environment. The typical JRE requires the services of an OS to interface with the universe off the CPU. I would expect their modified JRE has a number of those services built-in (services like networking, filesystem control, and console I/O) so that it can be booted in place of an OS.

Solaris *is* a version of UNIX. I believe it was originally based on System V Release 4. The earlier SunOS 4.0 was based on SysVR3, I think. And the even earlier SunOS 3.5 was based on BSD UNIX. (Please bear with me if I'm not exactly correct; I'm working on nearly 20 year old memories.)

I remember working on a software system that had to work, for testing purposes, on a number of OSen: SunOS3.5, SunOS4.x and Solaris; the target system was Motorola's 68K and 88K VMEbus-based SysV systems; there were even some SGI IRIX/MIPS-based systems in there. On the surface, you'd think it simple. But every compiler laid out data structures differently. It took research and careful planning to shape the code so that the system's binary data files were all cross-platform compatible. Another neat trick was writing a shell-script application front end that would detect the underlying OS and hardware and then run the proper binary. But I digress. :)

0

Ive been at it a few months and have written tyhe beginnings of an O/S (not an OS yet as it doesnt do the functions an O/S is designed to do by definition)

Currently it boots up from floppy using a simple ASM bootloader and it accepts character input from thet keyboard into a buffer, where it is then written to the screen. You can delete and start new lines.

Cool! The next step is to write open(), read(), write() and close() functions so you can open a file on a raw floppy, read it into memory, make changes, then write it to floppy.
Hmmm. Perhaps even better, make it a binary editor, so you can hand-edit your bootloader and 'OS'. At that point, your system is self-sustainable (that is, you use it to maintain and modify itself). And if you want to be really daring, use your editor to write new functions for your editor, save the new stuff to floppy, and patch the running code (put the new code somewhere in memory, copy an existing program instruction to it, and replace the original instruction with a jump to the new code; don't forget to leave a way to get back from the new code! You'll quickly gain a strong appreciation of higher-level languages and compilers.)

0

Ive been at it a few months and have written tyhe beginnings of an O/S (not an OS yet as it doesnt do the functions an O/S is designed to do by definition)

Currently it boots up from floppy using a simple ASM bootloader and it accepts character input from thet keyboard into a buffer, where it is then written to the screen. You can delete and start new lines.

Once you have got basic input and output from the keyboard and screen, if I were you I would think about implementing a memory manager in the not too distant future. You need some method of allocating and releasing memory to do most things - keeping track of what memory is currently in use, and what's not.

You could also try visiting

http://www.osdev.org/phpBB2/ or http://www.osdev.org/osfaq2/ (amongst others)

0

yeah, atm im working on:

*some sort of command interpreter.

*some sort of graphics abstraction layer which should be easier than adressing the video
memory directly. also, the ability to scroll up and down the screen would be nice

*some sort of filesystem - in comp/sci ive been studying linked lists and am thinking about making a basic linked list but dont fancy this in ASM

*ways to manipulating the f/s and the ablity to save the text entered onto a floppy

my aim is to get it working nicely on my cyrix 286 compatible with 4mb ram and dual 3.5" floppies

the floppy seems soooo much easier to cope with than a drive. btw, im not using C, just ASM.

The only pitfalls im encountering are to do with interrupts. Ive decided not to use them really, and just to poll reguarly.

reackon i may be able to get to this stage in a year maybe? might steal some ideas from something like visopsys or menuet

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.