A dedicated kernel for multi-threading applications.

Wednesday, January 25, 2017

Toro kernel compiled with FPC 3.0.0!

Hi folks! I just fixed system.pas to compile Toro by using FPC 3.0.0. Most of the work has been done on the way that system.pas handles AnsiStrings. In addition, I moved the project to github, so fell free to participate. I tested the tests examples and they seem working. However, I only tested on Win 10. I will test in Linux in the following days. 


Saturday, January 21, 2017

How compile and run Toro in Windows 10

Hi folks! This time I want to present how compile and run Toro in Windows 10. What am I going to explain? How to compile the example named ToroHello.pas and run it on a QEMU VM. In thw following, I explain this procedure in 7 steps. My environment is in a Windows 10 in a x86-64 architecture.

1) Install Git Bash for Windows:
I am using this as the command line to get the compilation on Windows. You can download it from https://git-for-windows.github.io/

2) Install Yasm:
Yasm is the compilator for assembler code. This is needed to compile the bootloader. You can download it from http://yasm.tortall.net/Download.html

3) Install FPC 2.6.4:
FPC is used to compile the code of toro. For the moment toro is based on FPC 2.6.4. You can download it from https://sourceforge.net/projects/freepascal/files/Win32/2.6.4/fpc-2.6.4.x86_64-win64.exe/download

4) Install QEMU:
QEMU is used to run the application compiled into Toro. You can download it from https://qemu.weilnetz.de/w64/

So far we have all the tools to compile and run ToroHello.pas. We need just to clone it and compile it.

5) Clone Toro code:
Go to the Git Bash for Windows and clone the toro code by doing:

git clone git@github.com:MatiasVara/torokernel.git

6) Compile the bootloader and tools:
Before compile any application with Toro we have to compile the bootloader and the tools to generate an image for the VM. To do so, just run Make in toro-code/test directory.

7) Compile ToroHello.pas
To do this, we rely on the script named CloudIt.sh. We have to run the following command in the toro-code/test directory:

./CloudIt.sh ToroHello

That's all folks! If everything goes well you will get a QEMU VM running ToroHello.pas. Please fell free to comment if any of the steps did not work for you. Matias

Wednesday, January 04, 2017

HTTP server by using socket multiplexing

Hi folks!
In this post I will show you part of the last experiments on sockets multiplexing. This has been added in Toro a couple or years ago, however, only now I could make an example that works. This is a simple example, i.e., a simple http server that prints a welcome message. To make it works, I spent the last month fixing bugs in the networking. Also, I fixed an important bug in the memory manager. In the following, I will show how socket multiplexing is used in the case of a http server. The code of the example can be found in tests/ToroHttp.pas. In this post, I am not going into details about how socket multiplexing works. I will try only to give a big picture.
Let's first discuss the code of ToroHttp.pas (see Figure 1). This is the main program. It defines the network handler, i.e., HttpHandler. Then, it sets the right methods, e.g., DoInit(), DoAccept().

Figure 1.

After that, the handler is registered by using SysRegisterNetworkService(). The kernel will execute the different methods. For example, the first method invoked will be HttpInit().

Figure 2.
The method creates a new socket that listens on local port 80. Then, when a new connection arrives, the kernel will invoke HttpAccept().

This method prints something and waits for new data from the remote host. When some data is received, the kernel executes HttpReceive().

Figure 3.
We implemented a simple Receiv method. It only reads all the data from the remote host, then it sends a welcome message, and finally it closes the connection. To tray the server, we use telnet to the IP of the guest. In the telnet client, we get:

In the Qemu VM, we see that the connection is received and then closed:

As I said before, I only explained some details about socket multiplexing. I used the http server as a running example. The whole example is hosted in toro repo so please fell free to clone it.

Matias Vara