源代码下载:
http://www.cn-dos.net/forum/attachment.php?aid=3573&checkid=01076&download=1
https://gro.clinux.org/frs/download.php/2009/C_code.rar
注意:C_code.rar文件纠正了回调函数无法使用浮点数操作的问题...
演示下载:
http://zhenlove.com.cn/cndos/fileup/files/gui_demo.rar
最新虚拟机(qemu-0.9.0-windows)演示:
http://zhenlove.com.cn/cndos/fileup/files/qemu-0.9.0-windows.rar
完整功能如下所述:
rtCell 实时微内核-具有下列功能:
1. 完全抢占的实时微内核结构,独立的内核栈,中断和系统调用均切换到内核栈执行;
2. 256(64、32)个优先级,0为最高优先级(系统保留),256(64、32)为空闲优先级;
3. 不同优先级任务完全抢占,同优先级之间可按先进先出或时间片轮转方式执行;
4. 在一系统(定时器服务)任务中实现内核定时器,用于超时等待内核对象、周期性定时器、任务延迟、一次定时(此时需定义一超时后执行的过程);此服务任务的优先级由其客户任务的最高优先级驱动,随之动态改变,以消除隐式优先级反转现象;
5. 提供任务(Task)、互斥锁(Mutex)、信号量(Semaphore)、位域标志(Flag定时器(Timer)、优先级消息(Message)和环形队列(Ring buffer)内核对象;
6. 任何内核对象用一整数ID标识,而非指针,从而可避免用户任务野指针的副作用,内核对象总数不超过61440(即60K);
7. 互斥锁支持优先级继承和优先级置顶协议,在创建时设置该协议,且总按优先级等待,优先级继承协议时仅支持同一互斥锁的嵌套调用,优先级置顶协议还可支持不同互斥锁的多次嵌套调用;
8. 其它对象的等待方式有:优先级等待和先进先出(节省内存)等待,在创建时设置;
9. 内核数据的同步,除在任务切换,及任务和内核之间切换堆栈时暂时关中断外,其它地方均以延迟过程调用(DPC)方式执行;
10. 任务对象支持异步过程调用(Window用语APC,相当于UNIX中的信号机制),从而可引导任务异步的执行一个过程(前提是任务栈不小于1024字节),此过程将在该任务下次被调度时执行;
11. 删除避免机制,拥有互斥锁的任务及处于占有状态的互斥锁均具有防止被删除的机制,要删除拥有互斥锁的任务必须自行终止或调用任务终止函数,而要删除任一个互斥锁则必须先使其处于空闲状态,即没有任何任务占有此互斥锁,否则禁止删除;
12. 对象命名机制,同类内核对象可用唯一的名称标识来获取其ID,达到引用目的。
13. 在内核中实现了中断的进出接口,因此用户中断处理只需写标准的C函数,而不必关心中断底层处理的细节;
14. 系统调用以陷阱指令(x86中int指令)实现,易于扩展到“内存保护”的进程模式;
15. 在内核库之外提供了一个简单的堆内存分配机制,用于内核对象动态内存分配时调用;
16. 支持毫秒级定时器,内核定时器周期为一毫秒;
17. 支持 X387/287 硬件浮点协处理器的任务状态保护,被动方式的任务浮点状态切换(开中断执行,由于使用了特权指令实现,因此只能在纯DOS实模式下或虚拟机X386/X387及后续机型上执行,而无法在Windows的DOS窗口中运行)。
giCell 视口裁减及消隐处理引擎-功能如下:
1. 完善而精巧的多视口裁剪和消隐处理引擎,与微内核rtCell紧密结合;
2. 真正的事件(或消息)驱动的多窗口(视口)技术,支持顶层窗口和透明窗口的显示和裁剪处理;
3. 当前支持Label、Edit、Botton、Slider、Listbox、TreeView和Checkbox控件,其中的Edit控件支持剪切、复制和粘贴(ctrl+x,ctrl+c,ctrl+v);
4. 支持窗口的平移、缩放,光标切换和窗口系统按钮,及窗口和控件的过程回调;
5. 基于透明视口(或窗口)的裁剪和消隐处理,可生成任何非矩形(多态)窗口,本示例中的三角形窗口就是基于透明视口来实现的;
7. 支持图形内存设备(GDC),有效避免窗口重绘时闪烁,易于实现视频及动画处理;
6. 内存需求小,窗口和控件的缺省状态均不使用GDC(而是采用直接屏技术),所耗内存小,因此实用性强,包括rtCell调度器、鼠标、键盘及图形驱动的库文件在DOS下仅77K。
关于可文件Engine.lib和mcOutLib.obj:
1. 考虑到DOS内存的限制,库文件Engine.lib中的rtCell内核仅支持32个任务优先级(因为优先级队列太占用内存),这样即使在640K内存下,也可创建上数百个内核及GUI对象,可满足一定规模的应用程序要求;
2. 库文件mcOutLib.obj是目录giCell\mcOSLib下文件的编译结果,用于处理任务的浮点协处理器(硬件)状态切换,任务浮点数状态初始化,内存分配,信息显示等操作(主要用于内核),用户也可自己编译giCell\mcOSLib目录下的文件,注意:Borland C/C++ 3.1可能无法识别其中的某些浮点数操作指令;
3. 文件MAIN.C是对Engine.lib使用的具体实例,在Borland C/C++ 3.1中编译时必须打开X387/287选项和C函数参数传递约定,此文件还对任何使用透明窗口来生成非矩形窗口,以及如何使用GDC生成动画进行了演示;
4. 注意其中的一些执行顺序:浮点数操作不得放到回调函数中执行,而只能在其它任务中执行(可从回调函数中向其它任务发送消息来实现),否则程序将进行无限循环;
5. 因为浮点协处理器的任务状态切换机制使用了特权指令,所生成的可执行文件只能在纯DOS实模式下或虚拟机X386/X387及后续机型上执行,而无法在Windows的DOS窗口中运行;
6. 由MAIN.C所生成的可执行文件在AMD机器DOS实模式、X86虚拟机qemu-0.9.0-windows以及Bochs-2.1.1下均执行良好,注意:生成的可执行文件依然是16位实模式。
压缩文件C_lib.rar中包含窗口及其子控件的源代码,演示文件MAIN.C和DateTime.c,以及一个专用于Borland C/C++ 3.1的工程文件。
注意:使用浮点数操作时最好把相关任务的栈设置到2K以上。
联系邮件:
taowentao_twt@163.com,
taowentao_twt@sohu.com
“附件2”是最新的纯DOS下演示。
Last edited by taowentao on 2007-6-21 at 10:16 PM ]
Source code download:
http://www.cn-dos.net/forum/attachment.php?aid=3573&checkid=01076&download=1
https://gro.clinux.org/frs/download.php/2009/C_code.rar
Note: The C_code.rar file corrects the problem that the callback function cannot use floating-point operations...
Demo download:
http://zhenlove.com.cn/cndos/fileup/files/gui_demo.rar
Latest virtual machine (qemu-0.9.0-windows) demo:
http://zhenlove.com.cn/cndos/fileup/files/qemu-0.9.0-windows.rar
The complete functions are described as follows:
rtCell Real-Time Microkernel - with the following functions:
1. Completely preemptive real-time microkernel structure, independent kernel stack, interrupts and system calls are switched to the kernel stack for execution;
2. 256 (64, 32) priorities, 0 is the highest priority (reserved by the system), 256 (64, 32) is the idle priority;
3. Different priority tasks are completely preempted, and tasks of the same priority can be executed in first-in-first-out or time-slice round-robin manner;
4. Implement the kernel timer in a system (timer service) task, which is used for waiting for kernel objects with timeouts, periodic timers, task delays, and one-time timing (at this time, a process to be executed after the timeout needs to be defined); the priority of this service task is driven by the highest priority of its client tasks and changes dynamically to eliminate the implicit priority inversion phenomenon;
5. Provide kernel objects such as tasks (Task), mutexes (Mutex), semaphores (Semaphore), bit-field flags (Flag timer (Timer), priority messages (Message), and ring buffers (Ring buffer);
6. Any kernel object is identified by an integer ID, not a pointer, thereby avoiding the side effects of wild pointers of user tasks. The total number of kernel objects does not exceed 61440 (that is, 60K);
7. Mutexes support priority inheritance and priority ceiling protocols, which are set when created, and always wait according to priorities. Only nested calls to the same mutex are supported in the priority inheritance protocol, and multiple nested calls to different mutexes can also be supported in the priority ceiling protocol;
8. The waiting methods for other objects are: priority waiting and first-in-first-out (saving memory) waiting, which are set when created;
9. For the synchronization of kernel data, except for temporarily disabling interrupts during task switching and stack switching between tasks and the kernel, other places are executed in the form of deferred procedure calls (DPC);
10. The task object supports asynchronous procedure calls (APC in Windows terms, equivalent to the signal mechanism in UNIX), thereby guiding the task to execute a procedure asynchronously (provided that the task stack is not less than 1024 bytes), and this procedure will be executed when the task is scheduled next time;
11. Deletion avoidance mechanism: Tasks that own mutexes and mutexes in the occupied state both have a mechanism to prevent deletion. To delete a task that owns a mutex, it must terminate by itself or call the task termination function, and to delete any mutex, it must first make it in an idle state, that is, no task occupies this mutex, otherwise deletion is prohibited;
12. Object naming mechanism: Kernel objects of the same type can be referenced by using a unique name identifier to obtain their ID.
13. The interrupt entry and exit interfaces are implemented in the kernel, so user interrupt processing only needs to write standard C functions without having to care about the details of the underlying interrupt processing;
14. System calls are implemented by trap instructions (int instruction in x86), which is easy to expand to the process mode of "memory protection";
15. A simple heap memory allocation mechanism is provided outside the kernel library for calling when dynamically allocating memory for kernel objects;
16. Supports millisecond-level timers, and the kernel timer period is one millisecond;
17. Supports the task state protection of the X387/287 hardware floating-point coprocessor, and the task floating-point state switching in passive mode (executed with interrupts enabled, because it is implemented using privileged instructions, so it can only be executed in pure DOS real mode or virtual machines X386/X387 and subsequent models, and cannot run in the DOS window of Windows).
giCell Viewport Clipping and Hiding Processing Engine - functions are as follows:
1. A perfect and delicate multi-viewport clipping and hiding processing engine, closely integrated with the microkernel rtCell;
2. Truly event (or message) driven multi-window (viewport) technology, supporting the display and clipping processing of top-level windows and transparent windows;
3. Currently supports Label, Edit, Botton, Slider, Listbox, TreeView, and Checkbox controls. Among them, the Edit control supports cut, copy, and paste (ctrl+x, ctrl+c, ctrl+v);
4. Supports window translation, zooming, cursor switching and window system buttons, as well as process callbacks for windows and controls;
5. Based on transparent viewports (or windows) for clipping and hiding processing, any non-rectangular (polymorphic) window can be generated. The triangular window in this example is implemented based on transparent viewports;
7. Supports the graphics memory device (GDC), effectively avoiding flickering when the window is redrawn, and is easy to implement video and animation processing;
6. Small memory requirements. The default states of windows and controls do not use GDC (but use direct screen technology), and the memory consumption is small, so it is practical. The library files including the rtCell scheduler, mouse, keyboard, and graphics driver are only 77K under DOS.
Regarding the files Engine.lib and mcOutLib.obj:
1. Considering the memory limitations of DOS, the rtCell kernel in the library file Engine.lib only supports 32 task priorities (because the priority queue occupies too much memory). In this way, even under 640K memory, hundreds of kernel and GUI objects can be created, which can meet the requirements of application programs of a certain scale;
2. The library file mcOutLib.obj is the compilation result of the files in the directory giCell\mcOSLib, which is used to handle the task floating-point coprocessor (hardware) state switching, task floating-point state initialization, memory allocation, information display, etc. operations (mainly for the kernel). Users can also compile the files in the directory giCell\mcOSLib by themselves. Note: Borland C/C++ 3.1 may not recognize some of the floating-point operation instructions in it;
3. The file MAIN.C is a specific example of using Engine.lib. When compiling in Borland C/C++ 3.1, the X387/287 option and the C function parameter passing convention must be turned on. This file also demonstrates how to use transparent windows to generate non-rectangular windows and how to use GDC to generate animations;
4. Pay attention to some execution orders: floating-point operations must not be placed in callback functions, but can only be executed in other tasks (can be realized by sending messages from callback functions to other tasks), otherwise the program will enter an infinite loop;
5. Because the task state switching mechanism of the floating-point coprocessor uses privileged instructions, the generated executable file can only be executed in pure DOS real mode or virtual machines X386/X387 and subsequent models, and cannot run in the DOS window of Windows;
6. The executable file generated by MAIN.C runs well under the AMD machine DOS real mode, the X86 virtual machine qemu-0.9.0-windows, and Bochs-2.1.1. Note: The generated executable file is still in 16-bit real mode.
The compressed file C_lib.rar contains the source code of windows and their sub-controls, the demonstration files MAIN.C and DateTime.c, and an engineering file specially for Borland C/C++ 3.1.
Note: It is best to set the stack of the relevant task to more than 2K when using floating-point operations.
Contact email:
taowentao_twt@163.com,
taowentao_twt@sohu.com
"Attachment 2" is the latest demo under pure DOS.
Last edited by taowentao on 2007-6-21 at 10:16 PM ]