Jump to content




Coroutine management system


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

#1 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 23 March 2015 - 11:30 PM

I have kind of written a corourine management system:

Multitasking manager

For some reason it does not fully work, but I guess it is the basics.

What does not work is that it does not draw the windows linked with the processes at the right moments.

Any help is appreciated

Thanks in advance

Creator

Edited by Creator, 24 March 2015 - 07:26 AM.


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 24 March 2015 - 12:27 AM

Split into new post. Please create a new topic for help with your code next time rather than using someone else's topic.

#3 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 24 March 2015 - 09:04 PM

Why is nobody answering? Is something wrong with the post? Is it unclear? Is my english bad?

Please tell so I can correct it and make the understandin of the post easier.

Guys I really need this help. It is the Core (litterally) of my OS, so if you want to see something nice comming completely for free, help me with this. It is all I am asking about.

Thanks in advance,

Creator

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 24 March 2015 - 10:03 PM

Have you read the "Read This Post Before Asking Questions" sticky post? Some of the tips toward the bottom may help you to more fully describe the issue and help people find the issue you're having. What you've described so far is essentially, "It doesn't work like I want it to," which does not give us much to go on.

#5 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 24 March 2015 - 10:24 PM

Thanks Lyqyd.

The exact problem is the following: I have this coroutine manager which has some threads. On the right side there is a button. If you click it a menu shows up and ou can choose between the different tasks. When I select a different taks, by clicking on the name, the screen goes black. Afterwards, when I change againg to the desktop, the manager draws the previous screen, but what is actually loaded is the Desktop. I have to click on one of the bottons that are on the desktop in order to draw the desktop. The issue is that is does not draw the current process.

I hope I have been clear enough,

Creator

PS: Thaks in advance ;)

The side menu is handled by the openMeny function. You can find the whole OS here. Currently I have put FileX as desktop because desktop was having some problems I am gonna fix tomorow.

To install TheOS, run this:

pastebin get 2DMDuHci TheOS.file

Then run this little script:

pastebin run UTSZHm5s TheOS.file

In the end run this command in the shell:

TheOS/Boot.lua

For some reason, when installed, TheOS does not work. I am fixing that tommorow. Now sleep time.

Edited by Creator, 24 March 2015 - 10:47 PM.


#6 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 25 March 2015 - 02:15 AM

This is a pretty complicated problem, a lot of code is involved

I'd recommend adding a 'log' function that saves things to a file
Then you can add some calls to it in your program(s), and see what might be happening

#7 Bomb Bloke

    Hobbyist Coder

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

Posted 25 March 2015 - 05:13 AM

I suppose this is the relevant code segment (from the bottom of the drawOpen() function - if you can spot where that is. Where's your indentation and spacing?!):

if switchRoutine then
  print(xVsProcess[evnt[4]])
  routines[activeRoutine].window.setVisible( false )
  print(activeRoutine)
  activeRoutine = xVsProcess[evnt[4]]
  print(activeRoutine)
  --os.pullEventRaw()
  --term.clear()
  routines[activeRoutine].window.setVisible(true)
  routines[activeRoutine].window.redraw()
elseif toDelete then
  if activeRoutine == xVsProcess[evnt[4]] then activeRoutine = "Desktop1" end
  if not xVsProcess[evnt[4]] == "Desktop1" then
   routines[xVsProcess[evnt[4]]] = nil
   routines[activeRoutine].window.setVisible(true)
   routines[activeRoutine].window.redraw()
  end
end

You don't seem to be checking if the new process's "hasRun" value is set, so if it hasn't executed anything yet, switching to it won't cause it to start.

If you delete the active process, causing the script to revert to the "desktop", then you don't redraw at all.

Note also that you should only need to trigger a window redraw immediately on switching to a process from another process; and since, at that time, you'll generally be calling window.setVisible(true) (which redraws for you), that means the only time you really need to call redraw() directly is when you close your menu. Speaking of which, that menu is going to cause havok with any timers or rednet messages your processes are trying to keep track of...

#8 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 25 March 2015 - 06:01 AM

Why would that cause problems to timers and rednet events? Also thank you for your help. ;)

Creator

#9 Bomb Bloke

    Hobbyist Coder

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

Posted 25 March 2015 - 06:13 AM

While the menu is open, you're pulling mouse_click events while discarding any OTHER events that occur. So if a script is waiting on eg a timer, that menu-handling code may well just throw it away; using os.pullEventRaw() with a filter doesn't stop it from removing other events from the queue, it merely prevents it from actually returning until it finds the exact event it wants.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users