OSDev.org
https://forum.osdev.org/

Should I follow Linux structure/functionalities?
https://forum.osdev.org/viewtopic.php?f=1&t=33285
Page 1 of 1

Author:  Thpertic [ Wed Oct 31, 2018 6:58 pm ]
Post subject:  Should I follow Linux structure/functionalities?

I've been working on my os for a little, but now I'm thinking about kind of restarting the project following one of the earlier Linux release. I didn't do so much things: I only set up a GDT, initialized the terminal and half of the memory manager (just physical).
Is it insane? I can find something about kernel 2.4 and above but it is still too complicated for now and I'd like a documentation or an explanation about the 1.0 kernel or even 0.x. Thanks to everyone

Author:  FusT [ Thu Nov 01, 2018 2:05 am ]
Post subject:  Re: Should I follow Linux structure/functionalities?

Documentation on the linux kernel is pretty much non-existing, unfortunately. The code itself is a mix of coding styles and conventions, mostly without any comments.
You can find all versions of the linux kernel on https://www.kernel.org/, download a version you'd like to get familiar with and start reading.

POSIX is pretty well documented so writing a linux-comaptible OS without copying any of the big heap of sh*t the linux kernel actually is might be a lot easier.

I'm not saying I don't like linux, I use and enjoy it daily. It's just that the code is a horrible mess.

Author:  iansjack [ Thu Nov 01, 2018 3:35 am ]
Post subject:  Re: Should I follow Linux structure/functionalities?

Perhaps you would find Minix easier to follow. It is very well documented.

Author:  glauxosdever [ Thu Nov 01, 2018 11:45 am ]
Post subject:  Re: Should I follow Linux structure/functionalities?

Hi,


It depends on your project goals. Do you want to do an OS compatible to Linux (or Linux-based)? Then do that. Maybe following POSIX would be easier for a start, rather than following Linux as a whole. Or maybe, you want to do a Linux distribution; if so, please see Linux From Scratch.

There isn't really any "right" or "wrong" here. A lot of people here are doing Unix-like OSes (which is fine, two of the most popular and admired OSes here, ToaruOS and Sortix, are Unix-like); these people usually do that to learn POSIX and/or to be able to port external software to their OSes, even if it's not optimal. On the other side, some people here are doing custom OS designs (which is fine, and I'm also going to do that after restarting OS development); these people usually want to experiment with something different. How security could be better (or worse), how performance could be better (or worse), how programming could be easier (or harder), etc. It depends on various factors: e.g. what do you feel like doing, how much time do you have, what do you want to achieve from OS development, etc. In short, it's up to you.


Regards,
glauxosdever

Author:  Thpertic [ Thu Nov 01, 2018 6:21 pm ]
Post subject:  Re: Should I follow Linux structure/functionalities?

I do want to make my own OS, not a Linux distro. I've read some of the POSIX documentation, but there is a list with all the functions source code. I mean, it is right to make a standard, but I started this project to learn not to copy. this means that I shouldn't follow the POSIX rules but should do it all by myself, right?

Author:  nullplan [ Fri Nov 02, 2018 1:55 am ]
Post subject:  Re: Should I follow Linux structure/functionalities?

Thpertic wrote:
I do want to make my own OS, not a Linux distro. I've read some of the POSIX documentation, but there is a list with all the functions source code. I mean, it is right to make a standard, but I started this project to learn not to copy. this means that I shouldn't follow the POSIX rules but should do it all by myself, right?


POSIX defines an interface. Implementation is up to you. For instance, POSIX does not define which of the interfaces is a system call and which is a library call. They might all be library calls. In fact, Cygwin is a library for implementing POSIX on top of Windows.

For example, POSIX defines that each process has one global working directory. I am a bit torn on this, but I think I'll implement this as a file descriptor: If you ditch open() et al. and only implement openat() as syscalls, then the CWD can just be an FD. As can the root. Only trouble is, most POSIX programs expect to inherit 3 FDs from their parent process, not 5, so either I would use some high-numbered predefined slots for these (which doesn't sit well with me as it imposes a ceiling on the number of FDs that otherwise wouldn't be there), or I have to translate between POSIX FDs and the FDs of my OS. Oh well, I guess for starters the first approach wouldn't be too bad.

POSIX also defines that a process is a container for threads, and the threads are actually running things, but Linux didn't care about this for a long time, and the "tasks" they have currently are some weird pick-and-mix between the two concepts.

Author:  FusT [ Fri Nov 02, 2018 1:56 am ]
Post subject:  Re: Should I follow Linux structure/functionalities?

I don't really see following a standard as "copying" as long as you don't actually copy any sourcecode.
The specification gives you an interface, how you implement it is up to you. That's not copying anything imho.

Author:  Thpertic [ Fri Nov 02, 2018 3:43 am ]
Post subject:  Re: Should I follow Linux structure/functionalities?

Ok, but how and where should I start then? It's too big the documentation and I can't start writing a random function and then spread to the others...

Author:  nullplan [ Fri Nov 02, 2018 4:06 am ]
Post subject:  Re: Should I follow Linux structure/functionalities?

POSIX deals with userspace, so you should design your userspace such that it will be possible to emulate the basic definitions of POSIX on it. For instance, POSIX defines what a process is, what a thread is, etc., so you need to think about these concepts yourself. How do you want to deal with tasks? Copy POSIX's design wholesale or make some tweaks that a userspace library has to sort out?

As for getting started: Before POSIX becomes important at all, you already need to have:
  • Multitasking
  • VFS
  • Whatever file systems
  • Volumes
  • Disk drives
  • Output devices
  • Input devices
  • System calls
running. That's quite a handful. Only then do you even have an environment any userspace can run in at all. That's quite a bit of ways you can go without looking at POSIX at all.

Author:  Thpertic [ Fri Nov 02, 2018 4:16 am ]
Post subject:  Re: Should I follow Linux structure/functionalities?

I think that the memory manager should be running too, right?

Author:  nullplan [ Fri Nov 02, 2018 12:11 pm ]
Post subject:  Re: Should I follow Linux structure/functionalities?

Thpertic wrote:
I think that the memory manager should be running too, right?

Well, that kinda goes without saing. The rest really depends on it.

Author:  zaval [ Fri Nov 02, 2018 4:31 pm ]
Post subject:  Re: Should I follow Linux structure/functionalities?

Thpertic wrote:
I've been working on my os for a little, but now I'm thinking about kind of restarting the project following one of the earlier Linux release. I didn't do so much things: I only set up a GDT, initialized the terminal and half of the memory manager (just physical).
Is it insane? I can find something about kernel 2.4 and above but it is still too complicated for now and I'd like a documentation or an explanation about the 1.0 kernel or even 0.x. Thanks to everyone

It's a waste of time. Personally, I don't like linux, I think it's a mediocre, of very poor quality piece of bloat. But it doesn't matter what I think, what does - the documentation, there is no such a thing in the "open source" world. they don't care. You would be faced with the mess of its code, and that's all. huge, non-structurized, it's unbearably useless and painfully unsuitable as a reference for an OS developing. Moreover, and it's my opinion, and position, I've told about already here, - I even avoid learning about linux internals to not screw up my understanding of how OSes work. good ones. You know, it's like advices to not learn "bad" languages, or not read "bad" books on the good languages. The same is for OS. linux is a "bad" OS. especially for learning and borrowing from it. One should get his/her hands dirty in the linux source only if they love the latter unconditionally and don't have anything better to do and still want to participate in its "evolving". :mrgreen:
And given this quote of you:
Quote:
I do want to make my own OS, not a Linux distro.

You seem to have the answer for you question already.

POSIX is not a linux at all. It's an API specification for those who worships unix or wants to make their OS run POSIX programs.

Author:  StudlyCaps [ Mon Nov 05, 2018 12:00 am ]
Post subject:  Re: Should I follow Linux structure/functionalities?

@Thepertic:
I find that early Linux source can be useful as a reference of an actual implementation of some basic concepts in x86, things like syscalls, page and context management can be difficult to implement when you have no working examples. However to limit yourself to a Linux-like or POSIX system is to neglect the biggest learning experiences in OS-dev IMO, which is to design your own techniques and mechanisms by which system and application interact.

I find this repo https://github.com/kalamangga-net/linux-1.0 to be a decent resource. It's a clone of the original 1.0 release of Linux. Obviously it's not a good example of how things should be done, but seeing one way of solving a problem can sometimes help you to form your own solutions.

@zavel:
I agree with every criticism you raise of Linux. I am curious though what you would consider a "good" OS by comparison?

Author:  SpyderTL [ Thu Nov 08, 2018 1:14 pm ]
Post subject:  Re: Should I follow Linux structure/functionalities?

If you want your OS to have compatibility with existing Linux applications, then you should use the POSIX API standards. If you want your OS to have compatibility with existing Linux drivers, you should use the Kernel module driver structure.

Otherwise, you are free to design your own system. I started from scratch, specifically because I wanted my design to make sense to me, rather than be influenced by other designs that may be going on 50 years old. The end result turned out to be something fairly similar to the Linux layout, so I probably would have saved years of effort if I had just started there, but I'm still glad that I went down that road, because I have a much better understanding and appreciation for both Linux and Windows.

I guess the moral is that as long as you are working in ASM and C (or probably even C++), your design will probably resemble Linux to some extent.

Just out of curiosity, what would you guys say is the most "alien" OS design compared to Linux and all of the other typical designs? On the surface, I'd say Haiku looks like it would be fairly different, internally, but I haven't actually looked into the internals that much.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/