Page 1 of 1

Task Handling (sorta)

Posted: Tue Oct 18, 2005 3:17 pm
by Warrior
I decided to implement Virtual Consoles (up to 4, not counting the "root" or "debug" console.)

Now my problem is, I want to be able to run more than one process at a time but eventually I would run out of VCs (after 4 tasks which need console I/O are spawned) and I don't want two processes running on the same VC.

What I have done, is something like "Task Queueing" where tasks wait in line for a spot in any virtual console.

Now the way the tasks are selected for each Queue is.

[pre]
TaskA in line for VC1
TaskB in line for VC2
TaskC in line for VC3
TaskD in line for VC4
[/pre]

Right now, all VCs are filled with executing processes but say another task is spawned now my function would loop through every VC, check how many people are in line, and find the shortest one. Example:

[pre]
Looping..found best (waittime: 1) in VC1
Looping..wait time the same in VC2, skip
Looping..wait time the same in VC3, skip
Looping..wait time the same in VC4, skip
[/pre]

It would then place you in line for VC1

Two things I was thinking of doing but am unsure about:
1. Allow higher prioritized tasks a "cut" in line.
2. Allow people waiting in line longer to go to less wait time places if for example:

[pre]
2 people in line for VC2
1 person in line for VC3
3 people in line for VC4
[/pre]

The oldest person who isn't the VERY next -OR- the VERY last would get a chance to move lines to a different VC with the least people (VC3)

Reason for not allowing it to be the very next:
It's bound to be next, give someone else a chance! :p

Reason for not allowing it to be the very last:
It just arrived, wait a lil. Although the odds of it not already being in best placement are slim.

Condition for being able to switch lines:
Lines must have less people than you (obviously)

Comments and suggestions are welcome.

- Nelson

Re:Task Handling (sorta)

Posted: Tue Oct 18, 2005 3:26 pm
by bluecode
hi,

I would use one wait-queue, which contains all the processes, which are waiting for a virtual console. Than if one console becomes free, you can go through the list, search for the highest priority process and give that process access to the console.
I'm not sure if my solution meets your requirements, it's just a suggestion :)