08-02-2003, 03:13 PM
okay, now it's clarified. but i have to comment on that.
in this example, your "driver" is part of the os really, hardcoded. it's not a driver... it's just another sub in my "os", which can be addressed with a special message. but i can think of a vm equivilent:
now i'll explain the algorithm a little -- vddConsoleRead is the trap that accepts app-requests. of course we need some driver-initializer, but that's not important to show for this example. anyway, once vddConsoleRead is activated, it initializes itself, enables a dormant hook (vddConsoleReadHelper) and suspends itself. now that the hook is enabled, it will trap keypress messages, digest them and spew out the equivilent ASCII char. when it returns, it resumes vddConsoleRead. notice that the hook does not LEAVE. LEAVEing is required only to resume the suspended caller of a trap. since the hook is called by the system directly, and because it RESUMEs vddConsoleRead manually, we do no need a LEAVE here.
vddConsoleRead will now continue after the SUSPEND instruction. if the char read is newline, or if the buf-length is greater than the allowed, it will exit the loop; otherwise, it will reiterate. when the loop exits, vddConsoleRead will disable the helper hook, so that system messages are processed normally. it releases chr, because it is no longer used. on the other hand, it does not release buf, because it holds the returned string. the program that requested vddConsoleRead should release it.
i'm still not done designing this language. for example, RETURN-MESSAGES would be more efficient than traps. for example:
;; get username
NEWSTR txt1, "Enter username: "
NEWSTR txt2, "Welcome "
SEND MSG_SYS_DISPLAY To SYSTEM (txt1, NA, NA, NA)
SEND MSG_VDD_CONSOLEREAD To DRIVERAPP (txt1, NA, NA, NA)
SEND MSG_SYS_DISPLAY To SYSTEM (txt2, NA, NA, NA)
SEND MSG_SYS_DISPLAY To SYSTEM (txt1, NA, NA, NA)
DELSTR txt
since the read buffer is returned to txt1, we dont need any messages here. but mathematical functions, for instance, return a value. so instead of passing variables, a special RETURN instruction can be made to send a message, leave the trap, and store the message in local variables, rather than on the queue (for instance, RET_INFO1, RET_INFO2, RET_INFO3, and RET_INFO4 - just like INFO1, INFO2, INFO3, and INFO4 store the trapped message)
hosted linux sounds interesting... and since i have redhat on my other partition... were can i get hosted linux? although i'm guessing this method is good for development, but you couldnt make a bootup this way. anyway. what are you researching by it?
[Flexibal>
Code:
' Virtual console driver read
sub consoleRead(length as integer, buffer$)
'Do the low level handling of key_up and key_down here
'and then put the resulting string in the buffer.
'The buffer could be returned to the user process by sending
'another message, or putting the buffer somewhere in memory
'and having a pointer returned (via a register or the stack in
'the VM) to the user-process.
end sub
in this example, your "driver" is part of the os really, hardcoded. it's not a driver... it's just another sub in my "os", which can be addressed with a special message. but i can think of a vm equivilent:
Code:
; this is the "console driver".
; the owner-id is subsituted for THISAPP when app is loaded
GLOBAL chr
; trap that eats MSG_CONSOLE_READ
; info1 = length
; info2 = return buffer (created by caller)
Trap vddConsoleRead: MSG_VDD_CONSOLEREAD To THISAPP By NA (NA, NA, NA, NA)
NEWINT c
NEWSTR chr ; create GLOBAL chr here
SETINT c, 0
SETSTR INFO2, ""
ENABLE vddConsoleReadHelper
redo:
SUSPEND vddConsoleRead
CMPSTR chr, "\n"
BNE redo
CONCAT INFO2, chr
INCINT c
CMPINT c, INFO1
BL redo
DISABLE vddConsoleReadHelper
DELSTR chr
LEAVE
End Trap
; hook that eats MSG_SYS_KEYPRESS (system message)
; info1 = scan code (sent by the keyboard handler)
; info2, 3, 4 = N/A
Hook vddConsoleReadHelper: MSG_SYS_KEYPRESS By SYSTEM To (NA, NA, NA, NA)
CMPINT INFO1, 16
BE L16
CMPINT INFO1, 17
BE L17
CMPINT INFO1, 18
BE L18
;...
CMPINT INFO1, 28
BE L28
; rest of scan codes
;--------------
L16:
SETCHR chr, "Q"
GOTO endofhook
L17:
SETCHR chr, "W"
GOTO endofhook
L18:
SETCHR chr, "E"
GOTO endofhook
; ...
L18:
SETCHR chr, "\n"
GOTO endofhook
; rest of ASCIIs
;--------------
endofhook:
RESUME vddConsoleRead
End Hook
now i'll explain the algorithm a little -- vddConsoleRead is the trap that accepts app-requests. of course we need some driver-initializer, but that's not important to show for this example. anyway, once vddConsoleRead is activated, it initializes itself, enables a dormant hook (vddConsoleReadHelper) and suspends itself. now that the hook is enabled, it will trap keypress messages, digest them and spew out the equivilent ASCII char. when it returns, it resumes vddConsoleRead. notice that the hook does not LEAVE. LEAVEing is required only to resume the suspended caller of a trap. since the hook is called by the system directly, and because it RESUMEs vddConsoleRead manually, we do no need a LEAVE here.
vddConsoleRead will now continue after the SUSPEND instruction. if the char read is newline, or if the buf-length is greater than the allowed, it will exit the loop; otherwise, it will reiterate. when the loop exits, vddConsoleRead will disable the helper hook, so that system messages are processed normally. it releases chr, because it is no longer used. on the other hand, it does not release buf, because it holds the returned string. the program that requested vddConsoleRead should release it.
i'm still not done designing this language. for example, RETURN-MESSAGES would be more efficient than traps. for example:
;; get username
NEWSTR txt1, "Enter username: "
NEWSTR txt2, "Welcome "
SEND MSG_SYS_DISPLAY To SYSTEM (txt1, NA, NA, NA)
SEND MSG_VDD_CONSOLEREAD To DRIVERAPP (txt1, NA, NA, NA)
SEND MSG_SYS_DISPLAY To SYSTEM (txt2, NA, NA, NA)
SEND MSG_SYS_DISPLAY To SYSTEM (txt1, NA, NA, NA)
DELSTR txt
since the read buffer is returned to txt1, we dont need any messages here. but mathematical functions, for instance, return a value. so instead of passing variables, a special RETURN instruction can be made to send a message, leave the trap, and store the message in local variables, rather than on the queue (for instance, RET_INFO1, RET_INFO2, RET_INFO3, and RET_INFO4 - just like INFO1, INFO2, INFO3, and INFO4 store the trapped message)
Quote:The exec system call is used to execute a new processwell, in my "os" there's a VMI_LOADAPP instruction, which loads an app from file. as for forking or spawning (the windows term), that is harder, because i'll need to duplicate all of the owner's traps (because traps trap messages sent to a specific owner usually).
Quote:Im currently doing a research/coding project for my University to make Solaris MINIX portable to other operating systems and architectures. Solaris MINIX is a real operating system that is hosted as a single process on top of Solaris. Each process is a real execuatable and runs directly on the CPU and the kernel swaps them in and out using ucontext structures. Signals are used to simulate interrupts and all of the device drivers have been replaced with virtual ones which make system calls to the host. Im not sure that system crashes would be impossible, you still need to interface with the host, so theoritically you could do something wrong and bring it down, of course it is a much more stable way to develop operating systems, which is why Hosted-Linux exists.
hosted linux sounds interesting... and since i have redhat on my other partition... were can i get hosted linux? although i'm guessing this method is good for development, but you couldnt make a bootup this way. anyway. what are you researching by it?
Quote:Your implementation is very accurate though.nice to know. you see, i didnt take computers at school, i took chem... because i used to like chem, and because what they teach i hate (pascal as an intro, and then two years of prolog - yuch!!). so i havent learned all the things and terms, and how they are implemented. instead i read about it, and mostly reinvent it myself.
[Flexibal>