This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
astonpl's profile picture

Multithread OS 1.3

Started by astonpl, 03 November 2012 - 06:26 AM
astonpl #1
Posted 03 November 2012 - 07:26 AM
AstonOs - 1.3v
[attachment=660:lua1_3.zip]

V 1.3:
- Fixed read(),write()
- Add new Shell
- Add ShellLoader
- Thread expended

Screenshoots:

[attachment=651:java 2012-11-05 19-26-38-25.jpg]
[attachment=652:java 2012-11-05 19-26-46-02.jpg]
[attachment=653:java 2012-11-05 19-26-51-79.jpg]
[attachment=654:java 2012-11-05 19-26-54-79.jpg]
[attachment=655:java 2012-11-05 19-27-00-76.jpg]
[attachment=656:java 2012-11-05 19-27-04-84.jpg]
[attachment=657:java 2012-11-05 19-27-08-67.jpg]
[attachment=658:java 2012-11-05 19-27-27-76.jpg]
[attachment=659:java 2012-11-05 19-27-40-07.jpg]

ShellX
It's alternative shell for deafult shell CraftOs. If u want run selected app or go to selected dir click right ctrl and press enter. LCtrl - show/hide menu enable/disable fust run. You can write commands to..

Avaible commands:
thread [file_name] [parameters ….] - run app in thread (thread [filename] [#hide] [parameters] - run in background now!)
jobs - show all runed thread
kill [pid] - kill thread thread
view [pid] - show thread ( In view click ctr to go to menu )

Services:
sys.ping - This program response for ping packages

Programs:
ping - App to send package to other computer

Apis:
aston.write( txt,id ) - write text to thread buffor of id
aston.print( txt,id ) - print text to thread buffor
aston.read( txt ) - create prompt -> thread buf
aston.numbertoside - convert number to side ( use in for )

aston.isprotocol(msg) - Check protocol of serialize date sended rednet
aston.getprotocol(msg) - Chceck name of protocol sended serialized date
astonos.setdefault(shellName) - Set default shell to shellName (ShellX or Shell)
Agrrrrr..!!
Now, U can open all applications in thread. For example : thread cp. You dont must use aston.write, aston.print,aston.read. Now functions (print,write,io.read) are automatical converted to thread IO method.

Sample Ping service runed in thread


-- sys.ping as_Ping(c) part of AstonOs(c)
print('Service is starting...')

opened = false

for i=1,6,1 do
side = aston.numbertoside(i)
if peripheral.isPresent(side) and peripheral.getType(side) == 'modem' then
	rednet.open(side)
	opened = true
end
end

if not opened then
   print("Modem isnt plugin")
   print("Servise is stoped")
   error()
end

while true do
who,msg,dst = rednet.receive()
if aston.isprotocol(msg) == 'ping' then
  print('Receive ping protocol from  #'..who,id)
  data = '{1,"reping","ok"}'
  sleep(1)
  rednet.broadcast(data)
  print('Send respone',id)
end
sleep(1)
end

If u run app in thread , normal io method will be auto converted
print(txt) ->aston.print(txt,id)
write(txt)->aston.write(txt)
io.read(question) -> aston.read(question,id)

where id is global variable in app. Id value is number app thread id
kazagistar #2
Posted 03 November 2012 - 08:02 AM
I was going to respond "you didn't add all that much functionality to call it a new OS"… but the bios.lua has an decent number of new functions. Binding each thread to its own terminal, and allowing you to switch between them is pretty neat.

I am just wondering what you hope this will be used for that is not served just as well by the parallel api?
astonpl #3
Posted 03 November 2012 - 09:34 AM
It's not ready os. Only to try.. :D/>/> I will work
ElvishJerricco #4
Posted 04 November 2012 - 11:16 AM
I wouldn't call this an OS but it's a heckuva threading utility
astonpl #5
Posted 06 November 2012 - 07:47 AM
f5 ^^