Crazed idea for a project. (0.0.1 is here -check out)
Crazed idea for a project. (0.0.1 is here -check out)
Another wave of insanity has hit me and now i'm overly excited about an idea what I'm seriously considering to turn into a project.
A DOS "shell" written in FB. Here's my idea:
Multitasking shell/kernel written in FB that can run and execute real exe's (compiled by FB). So sort of an OS that is based on DOS. Is anyone else interested in such thing?
A DOS "shell" written in FB. Here's my idea:
Multitasking shell/kernel written in FB that can run and execute real exe's (compiled by FB). So sort of an OS that is based on DOS. Is anyone else interested in such thing?
Last edited by VonGodric on Mar 12, 2006 19:34, edited 1 time in total.
Sounds good to me. I assume there will be some inter-application communications mechanism ?
I have an MS-DOS based TCP/IP server and everytime I want to add another server or access via Serial Port ( ie SLIP / PPP etc ) etc it means altering one horrendously monolithic program ( MS-DOS PowerBasic ). Being able to just write another simple FB App to do the job and have it hook into an internal TCP/IP stack would be superb.
Or I could / should use Linux :-)
I have an MS-DOS based TCP/IP server and everytime I want to add another server or access via Serial Port ( ie SLIP / PPP etc ) etc it means altering one horrendously monolithic program ( MS-DOS PowerBasic ). Being able to just write another simple FB App to do the job and have it hook into an internal TCP/IP stack would be superb.
Or I could / should use Linux :-)
Anyway believe it or not I got a threading library to work on dos version. I think DrV and V1ct0r could implement my library into official FB dos version to support threads natively
Although this library is somewhat still buggy and sometimes needs to call a yealding function to pass to a next thread
Although this library is somewhat still buggy and sometimes needs to call a yealding function to pass to a next thread
not pthreads -another small lightweight threads library. But it provides all the basics, threads, semaphores, conditions, thread priorities, and some more neat features. I think this should be sufficent to create a simple dos shell :P
Can someone test this on real dos machine? http://fbide.freebasic.net/File/fbthread.exe Works fine on my winxp box. Here's the src of this program
Can someone test this on real dos machine? http://fbide.freebasic.net/File/fbthread.exe Works fine on my winxp box. Here's the src of this program
Code: Select all
option explicit
#include "pdmlwp.bi"
dim shared print_limit as lwp_semaphore
sub threadTest1 ( byval usrData as any ptr )
do
lwp_wait_semaphore(@print_limit)
print "a";
lwp_release_semaphore(@print_limit)
loop
end sub
sub threadTest2 ( byval usrData as any ptr )
do
lwp_wait_semaphore(@print_limit)
print "b";
lwp_release_semaphore(@print_limit)
loop
end sub
sub threadTest3 ( byval usrData as any ptr )
do
lwp_wait_semaphore(@print_limit)
print "c";
lwp_release_semaphore(@print_limit)
loop
end sub
sub threadTest4 ( byval usrData as any ptr )
do
lwp_wait_semaphore(@print_limit)
print "d";
lwp_release_semaphore(@print_limit)
loop
end sub
dim thread1 as integer
dim thread2 as integer
dim thread3 as integer
dim thread4 as integer
if (lwp_init(0, 1024)) then
lwp_init_semaphore (@print_limit)
thread1 = lwp_spawn(@threadTest1, NULL, 4096, 1)
thread2 = lwp_spawn(@threadTest2, NULL, 4096, 1)
thread3 = lwp_spawn(@threadTest3, NULL, 4096, 1)
thread4 = lwp_spawn(@threadTest4, NULL, 4096, 1)
while inkey$=""
wend
lwp_kill( thread1 )
lwp_kill( thread2 )
lwp_kill( thread3 )
lwp_kill( thread4 )
end if
-
- Posts: 613
- Joined: Jun 15, 2005 13:22
- Location: Upstate NY
- Contact:
I'm interested by this too, a lot :-). great idea for a project
I don't have a DOS machine to test this on, but it worked here on XP Pro and XP Home.
I'll definitaly see where this goes, in a few weeks, I may have a native DOS machine then too....looking into it....then I could perform more tests when needed...i'd like to help too :-)..
Now who here didn't think I'd be interested?? Shame on you LOL...
I don't have a DOS machine to test this on, but it worked here on XP Pro and XP Home.
I'll definitaly see where this goes, in a few weeks, I may have a native DOS machine then too....looking into it....then I could perform more tests when needed...i'd like to help too :-)..
Now who here didn't think I'd be interested?? Shame on you LOL...
-
- Posts: 8631
- Joined: May 28, 2005 3:28
- Contact:
do you mean this ?
Pre-emptive multithreading library 2.0
ftp://ftp.delorie.com/pub/djgpp/current ... lwp20s.zip
Extended version of LWP library
ftp://ftp.delorie.com/pub/djgpp/current ... mlwp03.zip
Pre-emptive multithreading library 2.0
ftp://ftp.delorie.com/pub/djgpp/current ... lwp20s.zip
Extended version of LWP library
ftp://ftp.delorie.com/pub/djgpp/current ... mlwp03.zip
Hey guys. First proof of concept is here:
http://fbide.freebasic.net/File/fbos001.rar
It runs two files in a "multitask" mode. very simple, but it works:P is the code of the programs. one prints "a" and other "b"
http://fbide.freebasic.net/File/fbos001.rar
It runs two files in a "multitask" mode. very simple, but it works:P
Code: Select all
declare function fbos_Print alias "fbos_Print" ( strMessage as string )
function fbos_main alias "fbos_main" ( ) as integer
do
fbos_Print("b")
loop
end function
the higher is priority of the thread the more timeslices it get's.
Sleeping is done via not entering a thread at all for a given time -so there's almost no overhead because of it and on the contrary -if one thread is sleeping others get more time slices. double-locks? I van lock threading if it's needed and run in "single thread mode" until I don't need it anymore.
Sleeping is done via not entering a thread at all for a given time -so there's almost no overhead because of it and on the contrary -if one thread is sleeping others get more time slices. double-locks? I van lock threading if it's needed and run in "single thread mode" until I don't need it anymore.
But what about deadlocks? Say there are two threads, A and B, and two resources, X and Y. Thread A locks X for exclusive access. At the same time, thread B locks Y for exclusive access. What happens when thread A needs Y, which has been locked, while still having locked X? Thread A needs B to release its lock on Y, but B can only continue after A has released its lock on X.
Deadlock. Any way around it?
Deadlock. Any way around it?
yes I can see the problem. For a time being these situations must be avoided until I figure out how to solve it.
It is possible to check if the resource is locked and based on the result do appropriate action (sleep some milliseconds and try again? and if fails again fire an error or try to handle differently.) usually kernel must be able to run programs and if this kind of situation happens in the client program -then I can't do much about it.
It is possible to check if the resource is locked and based on the result do appropriate action (sleep some milliseconds and try again? and if fails again fire an error or try to handle differently.) usually kernel must be able to run programs and if this kind of situation happens in the client program -then I can't do much about it.