Hi i'm a newbie here & my questions are :

0- *what should i know to develop a library like the C standard library and if im thinking of building my own OS "im just dreaming" should i create a NEw C for it cause as we know C for linux isnt C for windows ??

1-*if kernel is binary codes how those codes manage other codes "application" o.O ??

2-*and what really happens when i press the right button and menu shows up in windows for example ??

what should i know to develop a library like the C standard library

You should have a strong foundation in C, but not necessarily the uncommon features. As an example, here's a simplified partial implementation of the C library that I wrote. In my estimation, anyone with decent knowledge of C could follow it without too much trouble barring three areas:

  1. The math library uses unions in a way that could be considered advanced.
  2. stdarg.h is very hackish and specific to the target compiler.
  3. The internal components depend on an understanding of the Win32 API.

if im thinking of building my own OS "im just dreaming"

Hardly, but writing an OS is among the most complex projects, if you want it to be more than a toy.

should i create a NEw C for it cause as we know C for linux isnt C for windows ??

C is a standardized language, so C for Linux is exactly the same as C for Windows until you start using platform-specific libraries. That happens quickly since any non-trivial program will likely call into the OS.

if kernel is binary codes how those codes manage other codes "application" o.O ??

The kernel is itself a program. A low level program to be sure, but still just a program. As concerns your question, I'm not sure I understand. Could you clarify what you mean?

and what really happens when i press the right button and menu shows up in windows for example ??

Overly simplified: The mouse sends a signal to the mouse driver, which in turn sends a right click message to the OS message pump. The active program then intercepts that message and handles it to open a menu.

Comments
show off

thnx for your reply m8, but in your last answer about "what happens ...." i think you just gived me an overview of what it happens sorry but i need a detailed explanation, including what happens physically ;) thnx again for your reply ;)

and concerning your liberary Oghh i didn't grasp anything i think i should learn learn and learn to understand better ;)

If you want to know how these low level features work, it you would be better off to learn assembly first. Especially if you want to learn about os developlemt. Learning some thing about compiler design will also be helpfull. I recommend you start off with programming in 8086 dos assmebly.

Making the c-standard libray is no different then making any other library. But you need to use the os provided libraries to power it, as deceptikon said. You might ask what provides the system provided libraries, and what powers the thing that powers those libraries. There is a bit of a trick to this "chicken and egg problem".

Let's take it all the way back to the compiler and the linker. The compiler will produce compiled code and put the code in some format, like MZ say.

There is also a little magic you can do. You know that you can use void pointers to pass function, right? Well, if you know the address of some code in your memory, you can call code that's not even in a library - as long as the code is formated the same way is it would be compiled by the compiler. This code can even be written in assembly, which is our trick.

Now let's say your writting an OS from scratch. The first thing your gonna want to do is write a bootsector in assembly that can search through the file system, and execute the MZ formatted kernal (presumably writtin in C). The bootsector should also load some functions in memory that give access to the "in" and "out" instruction wrappers.

Now, you have your C code running... But you don't have any libraries to work with. But, you know the address of the "in" and "out" instructions, and you know that some devices like the screen are directly mapped to memory. So now you have all you need to boostrap an entire OS.

If you wanted to, something small like an 8086 dos implementation is possible to do in a summer project. I'm not sure how many 8086 compilers you would be able to find, but writting your own compiler for another summer project isn't too bad either. Even if it's just as subset of C, or even some simpler language.

Edited 2 Years Ago by Hiroshe

can we code a kernel like linux kernel with just the c standard liberary ??

Ah Thnx for the web site its very useful thanx thnx thnx @Hiroshe ;)

can we code a kernel like linux kernel with just the c standard liberary ??

No. When the computer starts, you really don't have access to much - and certianly not the c standard library. Grub (which looks for the linux kernal, loads it, and runs it) does give a little bit to work with (like a memory map), but that's about it I'm afraid.

You can however write a kernal that doesn't use any libraries at all, using the void pointer manipulation I have already touched on. For example, you can read characters and write characters using some BIOS inturrupts in assembly, and writing it so it's compatible with your compiler, and use pointers to access the methods. That's as "close" to a library you'll get. But it is enough to implement the rest of the standard C library, as well as a kernal.

This article has been dead for over six months. Start a new discussion instead.