-2

I am interested in programming my own OS from scratch(in C). However, every tutorial I encounter has made a message print on the screen by writing directly to the VDU. Why can't I use standard library functions while writing my OS? I don't have much problem in writing directly to the VDU. However, it sometimes makes my mind utterly confused(especially in large programs).

Are the library functions not converted into the same low-level code as the functions created by us?

  • 3
    Because I/O functions use the OS. And the standard library functions do not use *your* OS. – Weather Vane Oct 01 '17 at 07:44
  • Also do you mean the *kernel*, or application programs? When you make the distinction, it is comparatively "trivial" to port a C library such as Newlib for your application programs – Antti Haapala -- Слава Україні Oct 01 '17 at 07:45
  • I mean 'kernel'. – Abhinav Jha Oct 01 '17 at 07:47
  • @WeatherVane "_your_ OS"? Which OS does it really use? – J...S Oct 01 '17 at 07:52
  • 1
    @J...S the OS that OP is writing. – Weather Vane Oct 01 '17 at 07:55
  • 1
    You want to use os functions . If you ask this question IMO it far too early for you to write own OS :) – 0___________ Oct 01 '17 at 08:04
  • My recollection is that output functions like printf() in glibc end up, by a tortuous route, in a call to sycall(), which stuffs certain values into registers and issues a trap to the kernel. You could, presumably, modify a library like glibc to link a syscall() implementation that is appropriate for another kernel -- but if you're writing a kernel, why use a big, heavy library to do something which your kernel must already be able to do? – Kevin Boone Oct 01 '17 at 08:07
  • I'm voting to close this question as off-topic because OP needsmuch more time to study language, OS-es, kernels etc before he will be ready for this task. – 0___________ Oct 01 '17 at 08:12
  • @PeterJ_01 I don't think an arrogant "OP will not understand the answer" is a valid close reason. – tofro Oct 01 '17 at 08:15
  • @tofro you did not understand the reason. \one needs to have a quite vast knowledge for this task. – 0___________ Oct 01 '17 at 08:44

1 Answers1

1

This is a kind of chicken-and-egg problem: Standard library functions use OS functions to print to the screen (deep down there, someone actually needs to write directly to the hardware).

Without an OS (because you just start writing one) this will not work. The standard library you want to use will need to be written specifically for and together with your OS.

tofro
  • 5,640
  • 14
  • 31