Jump to content




OS windows and Multitasking


  • You cannot reply to this topic
24 replies to this topic

#21 MadBudderKing

  • Members
  • 18 posts

Posted 04 May 2014 - 05:41 PM

Ive been wondering a little about that to, but thanks anyways to answer a question I never even asked to you. xD

Edited by MadBudderKing, 04 May 2014 - 05:41 PM.


#22 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 04 May 2014 - 05:59 PM

View PostMadBudderKing, on 04 May 2014 - 05:17 PM, said:

Now, to implement all the other drawing functions (paintutils.drawLine, drawPixel image, etc)

You don't actually need to re-implement all functions that use term API. You can either set their environment to the new sandboxed one or whenever you resume a program's coroutine (when you will implement 'multitasking') you can use term.redirect to redirect to the sandboxed (specifically for that program) term API (this is how Lyqyd OS manages displays).

View PostMadBudderKing, on 04 May 2014 - 05:17 PM, said:

Oh, and while im doing that, what about multitasking?
No-one talked about that, really in here yet

To make a multitasking system which would work with CC programs you first have to understand how CC events and coroutines work Lua side. (I will assume you already know how coroutines work)

To manage events CC uses coroutines. Whenever you run a program a new coroutine is created specifically for that program. Then that coroutine is resumed and CC waits for it to either yield or stop. When a coroutine yields (calling coroutine.yield, os.pullEventRaw or os.pullEvent) it may return some values. In CC it either returns an event filter or doesn't return anything (when you don't specify an event filter). If a filter was returned by a program CC waits for that specific event to fire, and when that event fires CC resumes the program passing that event and all parameters that came with it. If there was no event filter specified then CC resumes the program passing the first event it gets. I suggest you to look at how parallel API manages coroutines.

Note: 'terminate' event fires regardless of the event filter, be aware of that.

#23 MadBudderKing

  • Members
  • 18 posts

Posted 04 May 2014 - 06:17 PM

View PostMKlegoman357, on 04 May 2014 - 05:59 PM, said:

View PostMadBudderKing, on 04 May 2014 - 05:17 PM, said:

Now, to implement all the other drawing functions (paintutils.drawLine, drawPixel image, etc)

You don't actually need to re-implement all functions that use term API. You can either set their environment to the new sandboxed one or whenever you resume a program's coroutine (when you will implement 'multitasking') you can use term.redirect to redirect to the sandboxed (specifically for that program) term API (this is how Lyqyd OS manages displays).
Ya, I noticed :)

Also, lets say I give a program a designated area, like a 15*15 area. The program being ran in there wants to draw a image bigger then that.
The image is drawn outside the area, is there any special way to fix hat instead of drawing over it?

#24 CometWolf

  • Members
  • 1,283 posts

Posted 04 May 2014 - 06:32 PM

Use a screen buffer, and simply ignore any changes made to the area outside the window.

#25 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 04 May 2014 - 10:31 PM

For eg, a window.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users