Is OS development restricted to beginners?

Asked

Viewed 3,307 times

4

One thing I’ve always wanted to do is develop my own operating system (not necessarily as good as Linux or Windows, it would have some basic functions at prompt).

I’m not a complete beginner in this area, I already have a "base" in Assembly and C.

I’m having trouble finding guides on the same (It seemed to me quite restricted to beginners). I need suggestions :P (I can’t buy books)

  • Good quality literature you will find in articles and books (paid$). I recommend Operating Systems of Andrew Tanenbaum. I also recommend that you study the concepts of OS well and do not try to implement "from your head". A functional and bug-free OS is something extremely complex to develop from scratch. If you work with microcontrollers, there are many interesting alternatives to study. You can make modifications to the code, since most are available under a GPL license. Take a look at BRTOS is a wonder =D

  • I would say that to some extent it is rather restrictive, because it involves a very large range of factors that should be considered, on the other hand, any layman can make an OS from tutorials and projects that exist outside the internet. A guide you can use is the the.dev, there’s even a page on the subject: Necessary knowledge in english, take a look.

  • The C for Operating Systems is "freestanding". You have many limitations with freestnading C.

  • Some adventurers play games thereof in his spare time.

1 answer

18


I believe that many have wanted to do this, but note one thing, you can create your own "OS", but creating a core is a longer way, in other words to create a system you can make use of known cores, but to create a core it will be necessary to make almost of "zero".

If you use a Unix or linux kernel you can create an operating system (note that linux and Unix are not systems)

Creating a kernel from scratch can be complicated, see for example Macosx that uses a core based on the BSD kernel (depending on the source NAKED is a hybrid kernel combining version 2.5 of Mach kernel developed with components of 4.3BSD), the core of BSD was initially considered a branch Unix, so we can assume that it is derived from Unix.

If you are interested in creating a system you can acquire the linux kernel accesses the https://gnu.org

What is a core

In computing, the kernel (kernel) is the central component of the operating system of most computers; it serves as a bridge between applications and actual hardware-level data processing. Core responsibilities include managing system resources (communication between hardware and software components). Generally as a basic component of the operating system, a kernel can offer the lowest-level abstraction layer for the resources (especially processors and input/output devices) that application software must control to perform its function. It typically makes these facilities available to application processes through mechanisms of communication between processes and system calls.

Operating system tasks are done in different ways by different cores, depending on your design and approach. While monolithic kernels will attempt to achieve their objectives by executing all system codes in the same address space to increase system performance, microkernels run most system services in the user space as servers, seeking to improve the maintenance and modularity of the operating system. A range of possibilities exist between these extremes.

source: http://en.wikipedia.org/wiki/Kernel_(operating_system)

Note: A system does not need to have a complete graphical user interface, as in windows, this is usually an application on a higher level.

Creating a Kernel/Kernel

As said the core is something complicated, but since you have some knowledge then I will indicate you http://wiki.osdev.org/Creating_a_64-bit_kernel

Writing a core in C

The following shows how to create a simple C kernel. This kernel uses the buffer VGA text mode (located in 0xb8000) as the output device. It configures a simple driver that remembers the location of the next character in this buffer and provides a primitive for adding a new character. Notably, there is no support for line breaks (\n) (and writing the character will show some specific features of VGA) and there is no support for scrolling when the screen is filled. This example is just the first step. Please take a few minutes to understand the code.

#if !defined(__cplusplus)
#include <stdbool.h> /* C não tem booleans por padrão. */
#endif
#include <stddef.h>
#include <stdint.h>

/* Verifique se o compilador acha que, se nós estamos alvejando o sistema operacional errado. */
#if defined(__linux__)
#error "Você não está usando um cross-compiler"
#endif

/* This tutorial will only work for the 32-bit ix86 targets. */
#if !defined(__i386__)
#error "Este tutorial precisa ser compilado com um compilador ix86-elf"
#endif

/* Hardware text mode color constants. */
enum vga_color
{
    COLOR_BLACK = 0,
    COLOR_BLUE = 1,
    COLOR_GREEN = 2,
    COLOR_CYAN = 3,
    COLOR_RED = 4,
    COLOR_MAGENTA = 5,
    COLOR_BROWN = 6,
    COLOR_LIGHT_GREY = 7,
    COLOR_DARK_GREY = 8,
    COLOR_LIGHT_BLUE = 9,
    COLOR_LIGHT_GREEN = 10,
    COLOR_LIGHT_CYAN = 11,
    COLOR_LIGHT_RED = 12,
    COLOR_LIGHT_MAGENTA = 13,
    COLOR_LIGHT_BROWN = 14,
    COLOR_WHITE = 15,
};

uint8_t make_color(enum vga_color fg, enum vga_color bg)
{
    return fg | bg << 4;
}

uint16_t make_vgaentry(char c, uint8_t color)
{
    uint16_t c16 = c;
    uint16_t color16 = color;
    return c16 | color16 << 8;
}

size_t strlen(const char* str)
{
    size_t ret = 0;
    while ( str[ret] != 0 )
        ret++;
    return ret;
}

static const size_t VGA_WIDTH = 80;
static const size_t VGA_HEIGHT = 25;

size_t terminal_row;
size_t terminal_column;
uint8_t terminal_color;
uint16_t* terminal_buffer;

void terminal_initialize()
{
    terminal_row = 0;
    terminal_column = 0;
    terminal_color = make_color(COLOR_LIGHT_GREY, COLOR_BLACK);
    terminal_buffer = (uint16_t*) 0xB8000;
    for ( size_t y = 0; y < VGA_HEIGHT; y++ )
    {
        for ( size_t x = 0; x < VGA_WIDTH; x++ )
        {
            const size_t index = y * VGA_WIDTH + x;
            terminal_buffer[index] = make_vgaentry(' ', terminal_color);
        }
    }
}

void terminal_setcolor(uint8_t color)
{
    terminal_color = color;
}

void terminal_putentryat(char c, uint8_t color, size_t x, size_t y)
{
    const size_t index = y * VGA_WIDTH + x;
    terminal_buffer[index] = make_vgaentry(c, color);
}

void terminal_putchar(char c)
{
    terminal_putentryat(c, terminal_color, terminal_column, terminal_row);
    if ( ++terminal_column == VGA_WIDTH )
    {
        terminal_column = 0;
        if ( ++terminal_row == VGA_HEIGHT )
        {
            terminal_row = 0;
        }
    }
}

void terminal_writestring(const char* data)
{
    size_t datalen = strlen(data);
    for ( size_t i = 0; i < datalen; i++ )
        terminal_putchar(data[i]);
}

#if defined(__cplusplus)
extern "C" /* Use C linkage for kernel_main. */
#endif
void kernel_main()
{
    terminal_initialize();
    /* Como não há suporte para novas linhas em terminal_putchar ainda, \n irá produzir algum personagem específico VGA vez. Isto é normal. */
    terminal_writestring("Hello, kernel World!\n");
}

Compile using:

i686-elf-gcc -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra

Note that the above code uses some extensions and therefore we build as the GNU version of C99.

Then see the article: http://wiki.osdev.org/Creating_a_64-bit_kernel

Creating a system with GNU

In response: To develop an OS using linux or Unix needs Assembly? How can I learn Unix? - misakie

No Assembly is required to develop on GNU or GNU/Linux, as both are similar I will provide an example on C of GNU:

Creating my system based on an existing distro

Today many linux developers use as a base already existing distros, Ubuntu started being a Debian Fork, today is practically another distro, Linuxmint is a Ubuntu Fork. These distros already have enough support for drivers, ready programs (such as apt for example, which is the program update/installation/removal system and distro).

You can also use a ready-made distro and create your own GUI system such as Cinnamon, Gnone, Lxde and KDE.

For this you can use the http://www.linuxfromscratch.org/lfs/ or if you just want to create a custom Linux, you can follow the step by step in http://www.tecmundo.com.br/tutorial/26134-como-criar-uma-distribuicao-linux.htm

It will be necessary to be on an Ubuntu based system (in Window if it is not possible to do this):

Requirements

  • Ubuntu Builder;
  • ISO image of the distribution your system will be based on;
  • DEB Application Packages You Want to Make OS Default.

The installation of Ubuntu Builder can be done through the Ubuntu Terminal. Just type the following commands:

$ sudo add-apt-repository ppa:f-muriana/ubuntu-builder
$ sudo apt-get update
$ sudo apt-get install ubuntu-builder

After installing the Ubuntu Builder, It is time to execute it and start the process of creating its distribution. The first step to build your operating system is to select the ISO image of the distro on which it will be based. For this, click on the option Select ISO and browse the system directories to the one where the file is.

If you don’t have ISO yet, you can click on Get Ubuntu and mark the version of Ubuntu you want to download. When finishing the process and generating the file of your creation, Ubuntu Builder automatically downloads Ubuntu. But remember that this will cause the final process to take a little longer than usual.

Before proceeding with the selection of the apps and other features, fill in the fields displayed on the main screen with the distribution name, default username for the livecd and, finally, the nickname with which the machine will be identified when the system is running directly from the CD.

After that, the heavy lifting begins. At the right-most part of the screen, you will find eight configuration options, each of which is responsible for customizing a different item in the distro. Then check out what some of these buttons allow you to perform.

The first option allows you to select the graphical environment to be used by default in the distribution being created. In addition to the already known GNOME and KDE, it is also possible to select items such as XFCE4, LXDE, Openbox and Blackbox.

Editor sources.list

By clicking the second button in the left-most column, you can edit the list of application repositories used by the distribution to download and install most applications. Care must be taken at this stage not to remove items that compromise system integrity.

Install deb Packages

If you want your OS to have an application installed, but it cannot be found in the default Ubuntu repository, you can use the option Install deb Packages to add the installation packages of any program. DEB files must be present on your computer’s hard drive so they can be used.

Synaptic

The item Synaptic allows you to use Synaptic to add and remove packages or applications. Without a doubt, a great option for those who don’t have much patience to edit some of the above settings using the text editor.

After you configure all the features of your distribution, you can test the options by clicking the button Test, present in the upper right corner of the Ubuntu Builder interface. When everything is as expected, click on Build and wait until the process is finished and the ISO image of the OS is created.

On the button Settings from Ubuntu Builder, you can choose which action the application should take at the end of the procedure. You can, for example, cause the created ISO to be immediately recorded on a media.

The program has a wizard for creating the operating system, which can be activated with a simple click on the option Wizard. The setup process is very similar, and you can customize the same features. The difference is that Ubuntu Builder decides which items will be modified first.

Final considerations

In order not to have disk space problems while creating your distribution, make sure that there is at least 3 GB free on your computer’s hard drive. Also, having the DEB packages and Ubuntu (or Mint) image also helps make the process more efficient.

It takes a little patience while the ISO is built. Depending on the amount of modifications made and application inserted, the task can be quite time consuming.

Source: http://www.tecmundo.com.br/tutorial/26134-como-criar-uma-distribuicao-linux.htm

  • To develop an OS using linux or Unix needs Assembly? How can I learn Unix?

  • @misakie Since we don’t have "pure Unix", so I don’t know which Unix to tell you, I will edit the answer soon and provide an example with gnu/linux

  • 1

    Nice job +1 =)

  • 1

    Doubt resolved. Thank you William!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.