home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,010 of 2,978   
   Femme Verbeek to google@etherjones.us   
   Re: cooperative multitasking: how to dea   
   10 Jan 06 17:06:50   
   
   From: fv@nospam.tcenl.com   
      
   google@etherjones.us schreef:   
   > I still use TP7 with old DOS machines for lab data acquisition and   
   > control.   
   >   
   > I recently have been playing around with an excellent cooperative   
   > multitasking unit named "MTASK" written in the late 80's by Wayne   
   > Conrad.   
   >   
   > It seems to be very stable and does exactly what I want, *except* for   
   > the problem of "READLN":   When a task executes a READLN statement, you   
   > get stuck inside Borland's RTL code waiting for the user to key   
   > something in, and you can't release that time to the other tasks.   
   >   
   > So.....   
   >   
   > 1) Is there a version of the CRT unit which has been patched to do a   
   > far call to a user-defined procedure when it is busy waiting within the   
   > READLN code?   
   >   
      
   You could try the patch by Robert Prins. See the faq. But I don't think   
   this will work.   
      
   > or   
   >   
   > 2) Is there a unit (with source) which provides equivalent READLN   
   > functionality, that I could patch to add a call to the task switcher   
   > when the READLN is busy waiting?   
   >   
   You could make your own polling readln procedure.   
   Inside the poll loop the program should give the control back to the   
   operating system.   
   Something like this   
      
   uses crt,dos;   
      
   procedure yield;  {this procedure will free-up processor time when idle}   
   var    regs: registers;   
   begin   
       regs.AX := $1680;   
       Intr($2F,regs);   
   end;   
      
   function myreadln: string;   
   var s:string;   
        ch:char;   
   begin   
      s:='';   
      repeat   
        if keypressed then   
        begin   
         ch:=readkey;   
         write(ch);   
         if ch=#13 then write(#10) {linefeed}   
                   else s:=s+ch;   
        end   
        else yield;   
      until ch=#13; {enterkey}   
      myreadln:=s;   
   end ;   
      
   begin   
      writeln(myreadln);   
   end.   
      
      
   hth.   
      
   --   
   Femme   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca