Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!microsoft!johnte From: johnte@microsoft.UUCP (John TERRANOVA) Newsgroups: comp.sys.apple2 Subject: Re: pipes (implementation thereof) Message-ID: <53764@microsoft.UUCP> Date: 25 Mar 90 05:33:32 GMT References: <2284@tellab5.tellabs.com> <1990Mar23.200426.28446@spectre.ccsf.caltech.edu> Reply-To: johnte@microsoft.UUCP (John TERRANOVA) Organization: Microsoft Corp., Redmond WA Lines: 89 In article <1990Mar23.200426.28446@spectre.ccsf.caltech.edu> toddpw@tybalt.caltech.edu (Todd P. Whitesel) writes: >toth@tellab5.tellabs.com (Joseph G. Toth Jr.) writes: > >>First of all - in order to provide multi-tasking (which is refered to in >> the articles), the OS/Shell would have to work using interrupts. Most >> owners of Apples (][, ][+ //e - The //c includes a mouse interface which >> can generate timing interrupts) don't have clocks or mouse controllers >> to provide the timing interrupts required to provide multi-tasking. > >1. Only true pre-emptive multitasking requires interrupts. Cooperative > multitasking (a la Multifinder on the Mac) does not use interrupts to > decide when to change contexts. It would not be that hard to write a > cooperative multitasking system on ANY machine provided the O/S is > smart enough to provide the necessary intercommunication (pipes) and > to be able to load more than one program at once. Let me offer this definition of pre-emptive multitasking: The ability to execute more than one program at a time such that all programs get CPU time and no process(es) can prevent any other process(es) from getting control of the processor. The processes take turns controlling the processor. When the processes start ending, each remaining process gets more CPU time per unit real time. By this definition MultiFinder is not a pre-emptive multitasking system. Also by this definition interrupts are NOT required. All you need is some way for the OS/Shell to be able to decide it is time to task-switch and do the task-switch. A p-code system would be ideal for this. The 'time-slice' that a process has to run before being switched out would be a count of p-code instructions to execute. After the interpreter interprets some number of instructions, it switches tasks. This p-code system can also provide memory protection. If processes are allocated memory on a page basis then any memory access (read/ write and code or data) can be checked by the interpreter against a page table for validity. Another virtue of this hypothetical p-code system would be page- swapping. Since the code needs to be relocatable start it at memory location $0000. Which would be virtual page $00, byte $00. Using a page table, look up the physical page number for virtual page $00. If the physical page number is invalid, then load those 256 bytes from disk. I'll even give some code for the main loop of the interpreter (this code is not meant to be final code, but rather an idea of what the real code may look like): topOfLoop: lda timeLeft ;some zero-page location bne 1 ;keep going if time not expired jmp NextJob ;task-switch and jmp back to topOfLoop @1 dea sta timeLeft ldy vpage ;get virtual page number lda (currPageTable),y ; get phys page num from page table bne 2 jsr LoadPage ;page not in mem, so go get it @2 sta pc+1 ;store page number part of pc lda (pc) ;load the opcode inc pc ;bump up pc (using the vpage, not phys page) bne 3 inc vpage @3 asl tax jmp (jmpTable),x ;proc must end with jmp topOfLoop The last three instructions group the opcodes into 128 pairs. The pairs differ only in the high bit. The asl allows us to index into a jump table of words (2 bytes) rather than bytes. It is up to the code jmp'ed to to discern between the two opcodes by checking the carry flag. I have found that for simplicity, generation of the pcode may want to ensure that an entire instruction (1 byte opcode, >= 0 args) is on the same page so that checking for page faults during execution of instructions is not necessary - the eternal time-space trade off. So. Waddaya think? Is this pcode-multitasking-virtual memory system feasible? I think the key is a good pcode language. Anybody wanna write it? -----------------------+----------------------------+------------------------- John Terranova | What the Hell do I know? | I speak/type for me johnte@microsoft.uucp | I come from Waunakee! | and no one else. -----------------------+----------------------------+------------------------- "You look so good; you feel good, too. When they see you shake it, baby everybody's gonna pay attention to you and you and you." --Gerard, Shake It