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

How to make the Multitasking OS like OneOS?

Started by WattDev, 16 April 2017 - 10:37 AM
WattDev #1
Posted 16 April 2017 - 12:37 PM
Hi guys.
Today I stumbled on an amazing computercraft operating system.
It is named OneOS and it has a Multitasking system.
Can you guys please make a tutorial on how to make a Multitasking OS?
SquidDev #2
Posted 16 April 2017 - 12:50 PM
BB's Guide to Coroutines is a good starting point for learning about coroutines, and therefore implement multi-tasking. Read through the whole thing first: don't just skip to the multi-tasking section.

I'd also recommend looking at CC's multishell implementation.
Edited on 16 April 2017 - 10:51 AM
WattDev #3
Posted 16 April 2017 - 08:57 PM
BB's Guide to Coroutines is a good starting point for learning about coroutines, and therefore implement multi-tasking. Read through the whole thing first: don't just skip to the multi-tasking section.

I'd also recommend looking at CC's multishell implementation.
Sorry but I am not good at lua.
Video please?
SquidDev #4
Posted 16 April 2017 - 09:10 PM
Sorry but I am not good at lua.
Video please?

If you're not very good at Lua, I'd advise not starting with a mulit-tasking OS. I'd recommend having a read through the Programming in Lua book, try a couple of simpler tasks (turtle mining scripts, etc…) and then come back when you're more comfortable with the language. A video isn't going to make this any easier: you've just got to get more comfortable programming first, and sadly that takes time :)/>.
Edited on 17 April 2017 - 10:54 AM
WattDev #5
Posted 16 April 2017 - 09:27 PM
Hi guys
Today I am wondering how OneOS can execute a program in .program directory
and I want to do that in my own OS
Any answer???
houseofkraft #6
Posted 16 April 2017 - 09:41 PM
I agree to what SquidDev said. You should start off making basic programs first and then move to more advanced ones.
If you still want to do it, you can use the parallel API. With the API you are able to run multiple functions at once.

Example:

local function first() -- The function containing the first action
   while true do
       local _, key = os.pullEvent("key")
       print(keys.getName(key))
       os.sleep(0)
  end
end

local function second() -- The second action to execute at the same time
   while true do
       print("Press a key :D/>")
       os.sleep(0)
   end
end

parallel.waitForAll(first, second) -- Runs both functions at the same time.
Lyqyd #7
Posted 16 April 2017 - 11:44 PM
Threads merged. Please stick to one topic for questions about the OS you're thinking about building.
HaddockDev #8
Posted 17 April 2017 - 12:53 AM
SquidDev's right. If you want to make a multitasking OS, and you aren't that good at Lua: you are going to be in for a very long time.
Things you are going to have to learn: sandboxing, courotines, the event system, filesystem, a ton of Lua syntax, and much much more.

A good idea is to browse the CC wiki if your new to Lua because it will provide you with a lot of information and tutorials and such.

TL;DR: learn lots of lua, browse the wiki, use tutorials for help, and use Ask A Pro if your really stumped.
Dog #9
Posted 17 April 2017 - 01:38 AM
Since all of your questions seem to center around OneOS, I would suggest you take a look at OneOS' code to see how things were done.
WattDev #10
Posted 17 April 2017 - 06:35 AM
Since all of your questions seem to center around OneOS, I would suggest you take a look at OneOS' code to see how things were done.
*Sorry
But there's a ton of crashing bug in OneOS and I don't know how the program are used.
How do I do?
WattDev #11
Posted 17 April 2017 - 06:57 AM
Hi guys. Today I wanna know that is it possible to load a program as a Background Process?
Exerro #12
Posted 17 April 2017 - 12:54 PM
Execute program in .program directory: type in .program/some_program.lua in the shell and it'll run some_program.lua inside the .program directory.

Seriously though, if you don't know how to run a program, you shouldn't be making an OS. At best, you'll end up making a screen with a background that does nothing useful, at worst it'll… I don't think it gets any worse actually. For some context, oeed had years of experience before making OneOS and had made a previous OS that wasn't nearly as successful. They're not simple, and getting them right is very hard.

The other thing is motivation: if you're really determined to do this, it won't be easy. You'll have to get your head around new concepts, and learn things for yourself rather than just asking people for links to videos.

Whatever happens, you'll end up experimenting with code along the way, so why not just start out with the experimentation? Try to make some cool programs, tackle some problems in the Idea Exchange, or make a firework screensaver. Don't think of them as side projects, think of them as important parts on the way to making a second OneOS.

And the best of luck! CC could do with a decent OS.
Lyqyd #13
Posted 17 April 2017 - 04:14 PM
Threads merged. Stick to one topic for your OS-related questions.