China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 00:59
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Real-time microkernel: latest graphical mode multi-window demonstration View 12,252 Replies 39
Original Poster Posted 2005-08-15 18:04 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
rtCell ― Real-Time Microkernel (compilable with GCC 3.xx, Visual C++, and Watcom C++)
This kernel draws on principles from Minix, Windows NT, and Linux, and has the following functions:

1. Fully preemptive multitasking real-time microkernel. Task scheduling, waiting, and wake-up operations have good determinism (independent of the number of tasks).
Independent kernel stack; interrupts and system calls are all switched to the kernel stack for execution;

2. 256 priorities. 254 available priorities 1~254, 0 is the highest priority (reserved by the system), and 255 is the idle priority;

3. Different priorities can be fully preempted. Between the same priorities, tasks can be executed in first-in-first-out until blocked or in round-robin mode. The execution mode can be selected when the task object is created;

4. A kernel timer is implemented in a system (timer service) task, used for timeout waiting for kernel objects, periodic timers, and task delays. The priority of this (timer service) task is driven by the highest priority of its client tasks and changes dynamically to eliminate the priority inversion phenomenon;

5. Any kernel object is identified by an integer ID, not a pointer, thus avoiding the side effects of null pointers in user tasks. The total number of kernel objects does not exceed 32768 (i.e., 32K);

6. Provides kernel objects such as Task, Mutex, Semaphore, Flag, Timer, Message, and Ring buffer;

7. The mutex semaphore provides both priority inheritance and priority ceiling protocols, which are set at creation and always wait by priority;

8. The waiting methods for other objects are priority waiting and first-in-first-out waiting (to save memory), which are set at creation;

9. For synchronization of kernel data, except for temporarily disabling interrupts during task switching and when switching stacks between tasks and the kernel, other operations are performed using the deferred procedure call (DPC) mechanism;

10. System calls are implemented using the trap instruction (int instruction in x86), making it easy to expand to a hierarchical mode with "memory protection";

11. A simple heap memory allocation mechanism is provided in the kernel for dynamic memory allocation of kernel objects;

12. Interrupt entry and exit interfaces are implemented in the kernel, supporting interrupt nesting. The wake-up operations of Semaphore, Flag, Message, and Ring buffer can be executed in interrupts. When users handle interrupts, they only need to write standard C functions without caring about the details of the underlying interrupt processing.


The 32-bit kernel has been compiled successfully under Windows 2000, Mingwin 4.0 (GCC 3.xx), and Visual C++ 5.0/6.0;
The 16-bit kernel has been compiled successfully under Windows 2000 and Open Watcom C/C++ 1.3.

rtCell_vc5_sources.rar and rtCell_vc5.rar are the library files and source codes (serial communication, disk, and fat16 file operations) of the 32-bit real-time microkernel rtCell32. Please compile with Visual C++ 5.0/6.0.
Watcom_C16.rar is the DOS library files and source codes (only applicable to Open Watcom C/C++ ) of the 16-bit real-time microkernel rtCell;

bochs.rar contains the hard disk boot startup demonstration of rtCell in the "virtual machine software Bochs";
In this demonstration, the FreeDOS boot loader is used to load from the fat16 format file system to 0x600 for execution.


The 16-bit rtCell after compilation is about 50 K, including 4K statically allocated kernel stack and more than 4K other kernel data;
The 32-bit rtCell after compilation is about 87 K, including 8K statically allocated kernel stack and more than 4K other kernel data.


The 32-bit rtCell was tested for stability and reliability for 10 consecutive days on a "Lenovo machine" with P4, 1.7G, and 256 M memory.

E-mail: taowentao_twt@163.com

Click the hyperlink to download the file:

Attachment 2:
rtCell_vc5.rar (2005-12-16 05:38 PM, 127.07 K)
http://www.cn-dos.net/forum/attachment.php?aid=623&checkid=69e88&download=1

Attachment 3:
bochs.rar (2005-12-19 10:00 AM, 849.1 K)
http://www.cn-dos.net/forum/attachment.php?aid=655&checkid=c4727&download=1

Attachment 4:
rtCell_vc5_sources.rar (2005-12-19 10:04 AM, 127.07 K)
http://www.cn-dos.net/forum/attachment.php?aid=656&checkid=69e88&download=1

The following are demonstrations of 16-bit DOS real-mode mouse (PS2 ordinary serial port mouse) and keyboard applications and their available library files;

demo.exe is a demonstration of mouse (PS2) and keyboard applications in pure DOS. Note: The mouse cannot be used in the DOS window of (Win98/2K/XP);

KERNEL.SYS is used for the mouse and keyboard demonstration loaded and started by the Free DOS free loader;

rtCell16.lib is the 16-bit library file of the real-time microkernel rtCell (only applicable to Open Watcom C/C++);

rtPC_input.obj is the mouse (PS2) and keyboard input obj file for corresponding I/O operations. The source code can be found in FreeDOS-32 release 0.0.5;

sys_demo.bat and EXEFLAT.EXE are used to generate KERNEL.SYS from demo.exe for loading and starting by the Free DOS free loader.

True multitasking, multi (text mode) window demonstration:

Interrupt-driven mouse and keyboard, event-driven multi-window, true multitasking, fully preemptive real-time microkernel;

The red title is the active window, the blue title is the inactive window, and the inactive window can be dynamically refreshed in the background;

One window displays the task status, the other two windows display the current time and the word "window", and the desktop displays keyboard input;

The mouse can be used to move, activate windows, and change window size (at the lower right corner of the window).

Press "ctrl + z" to switch to the task status window.

Attachment 1: qemu_0.8_domo.rar contains the demonstration on the virtual machine. Unzip it, execute rtCell.bat, and click the window with the mouse;
Download link:
http://www.cn-dos.net/forum/attachment.php?aid=807&checkid=972c0&download=1

Attachment 2: dos_demo.rar (demo.exe and demo_.exe) is used to demonstrate with a serial mouse in pure DOS (no mouse in the Windows DOS window).
Download link:
http://www.cn-dos.net/forum/attachment.php?aid=854&checkid=12353&download=1


Latest graphical mode multi-window demonstration

giCell true graphical mode multi-window – all source codes (C language) are less than six thousand lines, and have the following functions:

1. Perfect and delicate multi-viewport clipping and hidden surface removal processing, tightly integrated with the real-time microkernel rtCell;

2. True event (or message) driven multi-window technology, and supports top-level windows and transparent windows;

3. Currently supports Label, Edit, Botton, Slider, and Checkbox controls. The Edit control supports cut, copy, and paste;

4. Supports window translation, scaling, and window system buttons, and process callbacks for windows and controls;

5. Small memory requirements (less than 64K), and the memory consumed by windows and controls is very small, so it is highly practical. Including rtCell, mouse, keyboard, and graphics driver, it is only more than 100 K bytes in DOS.


Demonstration method: Unzip gui_Test.rar, execute gui_Test.bat under Windows (double-click),

or directly execute bc_gui.exe under pure DOS (no mouse in the DOS window of Windows).

Note: In this demonstration, bc_gui.exe is relatively large due to including an illustrative bitmap.

Download address: http://zhenlove.com.cn/cndos/fileup/files/gui_Test.rar

[ Last edited by taowentao on 2006-10-5 at 22:24 ]
Floor 2 Posted 2005-08-17 10:37 ·  中国 香港
银牌会员
★★★
阿林
Credits 1,410
Posts 497
Joined 2004-06-28 00:00
22-year member
UID 27551
Gender Male
From 九龍,香港
Status Offline
Brother taowentao:

Do you have a ready-to-use boot disk? It's too basic, I can't understand...
How to test without a program?

Thanks!
我 的 網 站 - http://optimizr.dyndns.org
Floor 3 Posted 2005-08-17 11:20 ·  中国 香港
银牌会员
★★★
阿林
Credits 1,410
Posts 497
Joined 2004-06-28 00:00
22-year member
UID 27551
Gender Male
From 九龍,香港
Status Offline
Brother taowentao:

Do you have a ready-to-use boot disk? It's too basic, I can't understand...
How to test without a program?

Thanks!
我 的 網 站 - http://optimizr.dyndns.org
Floor 4 Posted 2005-08-22 12:12 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
The file is too large to upload; no matter how you compress it, the file size exceeds a megabyte.
Go to "http://www.h7.dion.ne.jp/~qemu-win/" to download the emulator with the freedos image disk, and replace the kernel.sys in it with the kernel.sys I made, but it can only be used for demonstration;
To add your own functions, you must compile it yourself and reprocess it with exeflat in the tools\ directory, then replace it.

Now rtCell can handle hard disk reading and writing in an interrupt mode (more efficient than busy waiting; some dos systems use busy waiting to handle hard disk reading and writing), and can read the fat16 file system. When I sort it out, I will upload it.


Extract the rtCell_img.rar and Qemu.rar to the same folder (without any subdirectories), double-click (execute) rtCell.bat (execute the x86 virtual machine), and you can see the execution of rtCell in the virtual machine. One of the tasks is reading and displaying the bochsrc.txt file in the root directory of the rtCell.img [ Last edited by taowentao on 2005-8-23 at 16:10 ]
Floor 5 Posted 2005-08-23 16:12 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
Extract rtCell_img.rar and Qemu.rar to the same folder (without any subdirectories). Double-click (execute) rtCell.bat (execute x86 virtual machine), and you can see rtCell running in the virtual machine. One of the tasks is reading and displaying the bochsrc.txt file in the root directory of rtCell.img.

[ Last edited by taowentao on 2005-8-23 at 16:17 ]
Floor 6 Posted 2005-08-26 10:49 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
rtDisk.c is used for disk reading and writing, executed in an interrupt mode; modified from "TINOS build 206", changing busy waiting to non-busy waiting, and moving the time-consuming parts of the interrupt operations to tasks for completion;

rtFat16.C is used for reading and writing files in the FAT16 root directory, modified from http://www.ifi.unizh.ch/ailab/embedded/multitaskers/embedpc.zip, changing its BIOS interrupt calls to disk reading and writing of rtDisk.c;

**********************************************
***** Note: There is a problem with file write operations, which has not been resolved yet ****
**********************************************


rtKB\rtKB.C is used for keyboard reading operations, modified from "TINOS build 206", moving the "time-consuming parts of keyboard interrupt operations" to tasks for completion;

Using these three files does not indicate their usability, nor does it guarantee their reliability; it is only used to illustrate the usage of rtCell, verify the performance of rtCell, and examine the stability of rtCell.
cstrt086.asm is a modification I made to the startup file of Open Watcom C/C++ 1.3, changing the startup address cstart of the program to 0000:0000, making it easier to relocate the program, so that EXEFLAT.EXE (only for 16-bit DOS real mode) can be used to generate executable image files;

sys_demo.bat is a batch file that turns demo.exe into KERNEL.SYS that can be booted from the hard disk by the FreeDOS boot loader

demo.exe can be run in DOS real mode; KERNEL.SYS is used to replace the KERNEL.SYS of FreeDOS (you can rename the KERNEL.SYS of FreeDOS), to achieve hard disk booting by the FreeDOS boot loader;

When pressing keys 5 and 6 respectively, it shows that the two tasks at positions 5 and 6 are deleted respectively,
When pressing keys a, b, c, A, B, C respectively, it shows the two tasks at positions 5 and 6, and the rtDisk task are suspended and resumed respectively,
When pressing keys t and T respectively, the timer interrupt is disabled and enabled;
osKeyBorad is the root task, which is started to create other tasks and also do keyboard processing;
For detailed information, refer to the source code: MAIN_rrsh.c, and the executable file is demo.exe;

*******************************************************
*** These two files are best executed in a virtual machine or emulator to avoid damaging hard disk data ***
*******************************************************


The interrupt setting function is changed as follows:

typedef void _cdecl (* PISR)(void *);

/* Set interrupt processing procedure:
* pISRAddr indicates the address of the interrupt processing function,
* wdIndex indicates the interrupt vector number,
* ppISRArg is a pointer to the pointer that stores the parameters of the interrupt processing function (the parameter of the interrupt processing function is a pointer, ppISRArg is a pointer to a pointer, that is, *ppISRArg is the parameter of the interrupt processing function), and at the same time *ppISRArg returns the address of the old interrupt processing function;
* If the interrupt processing function has no parameters, and you want *ppISRArg to return the address of the old interrupt processing function, you should point ppISRArg to a pointer, and let *ppISRArg = NULL; If the interrupt processing function has no parameters and you don't want *ppISRArg to return the address of the old interrupt processing function, then you can set ppISRArg = NULL.
*/
extern CWORD _cdecl SetVector(PISR pISRAddr, WORD wdIndex, void **ppISRArg);



In conclusion, this program demonstrates the idea of "microkernel operating system": interrupts are used to collect data, and tasks are used to process data; this can not only ensure the response ability of interrupts, but also ensure the priority execution of key data processing; thus, it is beneficial to ensure the real-time performance of the entire system; of course, rtCell itself being a real-time kernel is the basis for ensuring real-time performance.

If any friend has questions, new ideas, or finds errors, please contact: taowentao_twt@163.com

When using this demonstration, there should be a bochsrc.txt file in the root directory of drive C, otherwise an error will occur!

[ Last edited by taowentao on 2005-8-26 at 10:57 ]
Floor 7 Posted 2005-08-28 10:41 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
rtDisk.c is used for disk reading and writing, executed in an interrupt manner; the source code has more than 400 lines;

rtFat16.C is used for reading and writing files in the fat16 root directory, the source code has more than 620 lines;

It is very suitable for file reading and writing operations in embedded systems.
Floor 8 Posted 2005-08-28 10:59 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
In the <<China DOS Union Forum>>, I saw many domestic experts. Why is there no one willing to cooperate and jointly develop a domestic multi-tasking DOS system?

Even if it's just making a boot disk!

Now the file reading and writing in the root directory of FAT16 are basically available. Looking forward to experts joining to improve it!
Floor 9 Posted 2005-08-30 08:25 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
rtDisk.c is used for disk reading and writing;
It does not call any BIOS interrupts;
Instead, it is based on the functions of the microkernel rtCell, executed in an interrupt manner, and directly operates hardware ports;
Completely independent of BIOS.

The rtCell_demo.rar contains this file.


[ Last edited by taowentao on 2005-8-30 at 08:26 ]
Floor 10 Posted 2005-08-31 09:34 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
If you think the speed of disk reading and writing in rtDisk.c is relatively slow, you can add DMA operations, but you need to handle a series of operations such as DMA interrupts by yourself.

In addition, file reading and writing should prevent the destruction of data consistency when multiple tasks operate simultaneously: you can add a protection lock; you can also perform file reading and writing in a client/server mode, which can bring great flexibility (such as multi-user reading and writing permission grading, etc.), but it also brings performance loss.
Floor 11 Posted 2005-09-10 10:37 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
Is there any friend willing to cooperate, write a (or rewrite) operations such as fat, ntfs file reading and writing? It can be based on the server/client mode, or directly in the form of function calls.

Looking forward to those interested to join in cooperation!!!

Thank you!!!
Floor 12 Posted 2005-09-28 11:22 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
rtCell has been ported to 32-bit protected mode, and the following hard disk image files are available. Please run it with the qemu emulator. Still load it with the freedos boot loader. Supports 4G memory.

[ Last edited by taowentao on 2005-9-28 at 11:30 ]
Floor 13 Posted 2005-10-06 15:21 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
Note: The first 5M (0-4M) of memory has been reserved by the real-time microkernel and should not be used; users can freely allocate and use memory from 5M (5-4000M) onwards.

makefile, lk16_32.exe, make.bat, start16.sys, kernel.o, mcCLib.h, compile.h, TypeDef.h are compilation scripts, linking tools, and library files, and should not be changed;

After compiling (executing makefile), execute make.bat, copy the generated kernel.sys to the root directory, and it will be loaded by the freedos boot loader to enter the 32-bit real-time microkernel rtCell32.

void _cdecl rtShell(void); is a shell task for initializing user tasks, and users must provide this function; the initialization priority of this shell task is 1, and it has no parameters.

And rtShell.c is the only user file compiled by the compilation script makefile, please provide the function: void _cdecl rtShell(void) in it.

The above files have been compiled successfully under mingwin 4.0 (gcc 3.23/3.42).

[ Last edited by taowentao on 2005-10-6 at 15:29 ]
Floor 14 Posted 2005-10-07 13:59 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
There is a bug in the Mutex top - level protocol in the 16 - bit rtCell. The bug has been fixed in the 32 - bit kernel rtCell32. Therefore, do not use the Mutex of the top - level protocol in the 16 - bit rtCell. In addition, the header files of the 32 - bit kernel rtCell32 have been changed.
Floor 15 Posted 2005-10-08 15:31 ·  中国 辽宁 沈阳 联通
高级用户
★★
Credits 739
Posts 111
Joined 2004-11-30 00:00
21-year member
UID 34209
Gender Male
From 辽宁沈阳
Status Offline
Added task switching save and restore hook functions, which can be used to save coprocessor state. There are virtual demonstration programs and library files in the attachment.

[ Last edited by taowentao on 2005-10-8 at 15:36 ]
Forum Jump: