Re: TIB: Re: Multitasking


[Prev][Next][Index][Thread]

Re: TIB: Re: Multitasking




>> The key word is HALT. It's not multitasking if one of them is halted.
>> But who would need a real multitask anyway? Nobody needs back-
>> ground operation. This, if it works, would satisfy the original question.
> 
> How can two programs run on the same processor at the same time?
> They can't, unless you have a parallel processing.

Obviously, the calculator cannot execute two different cmmands
simultaneously. That is never what I meant. The background
program(s) would just get a few brief milliseconds to run every
second, handled by an interrupt routine. Either way, it doesn't
matter. My point was that this was not possible with any existing
programs. I never even said the calculator could run programs
in the background (although it can).

> Off the top of my head 
> there are two types of multitasking: cooperative and preemptive. 
> Cooperative is where the programs yield to others so they get a chance to 
> run. Preemptive is where the kernel sets up an interrupt so that every 
> once and a while a program's (yielding or not) control of the processor 
> is ripped away and the kernel gives another program the chance to run. A 
> real life example is the Mac OS is both. Programs running on a Mac are 
> engaged in cooperative multitasking, while the OS has preemptive tasks, 
> such as the cursor, device managers and the likes.

I looked it up:

Multitasking:
The ability to execute more than one task at the same
time, a task being a program. The terms multitasking
and multiprocessing are often used interchangeably,
although multiprocessing sometimes implies that more
than one CPU is involved. 

In multitasking, only one CPU is involved, but it
switches from one program to another so quickly that
it gives the appearance of executing all of the
programs at the same time. 
There are two basic types of multitasking:
preemptive and cooperative. In preemptive
multitasking, the operating system parcels out CPU
time slices to each program. In cooperative
multitasking, each program can control the CPU for
as long as it needs it. If a program is not using the CPU, however, it can
allow
another program to use it temporarily. OS/2, Windows 95, Windows NT, the
Amiga operating system and UNIX use preemptive multitasking, whereas
Microsoft Windows 3.x and the MultiFinder (for Macintosh computers) use
cooperative multitasking. 

>> To sum up on the multitasking discussion:
>> 
>> Doing true multitasking in TI-BASIC is proveably impossible.
>> Yes, you could do a function that saves important variables, but you
>> cannot break from the middle of a Tetris game to do physics and then
>> expect to return to the exact point you stopped. You simply do not have
>> the interrupt option. This could be put into the program but not
>> efficiently. The program would have to ask constantly if you want to
>> interrupt, and nothing else would ever happen.
> Not true. I have written a cooperative multitasking OS in TI-BASIC. The 
> main problem is switching folders which takes up a considerable amount of 
> time if you want instruction by instruction code. However, I can get a 
> couple of counters and drawing programs moving at an okay clip. To play 
> tetris you would need to convert the program into a list of strings 
> (mostly time, little skill needed). After a program is written all one 
> needs is set a priority to the program and the game runs at an almost 
> normal speed.
> 
> If anyone wants a copy of the os/kernel let me know <mikev@iserv.net>
> 
>> Thus, multitasking will not be done in TI-BASIC.
>> Good points and ideas have come up, people have discussed them in a
>> constructive manner, and they might be useful in other contexts.
>> However, the cold, hard fact remains that we can't do cost-efficient
>> (pseudo-)multitasking using TI-BASIC alone.
> 
> If you can dream it, someone can program it.

If you can dream it and you have an infinite amount of RAM and
speed is not an issue, someone can program it. The 92 has an
advantage with folders. It would be impossible to support every
basic program on the 8x. Saving vars A-Z is the only feasible way
and would cover every basic program I ever wrote, but even then,
the resources needed would be horrendous. In conclusion: it may
be partially possible, but it is definitely not worth it.


Follow-Ups: