Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!nbires!maa From: maa@nbires.UUCP (Mark Armbrust) Newsgroups: comp.sys.ibm.pc Subject: Re: BACKGROUND PROCESSES UNDERS DOS Message-ID: <1206@nbires.UUCP> Date: Thu, 9-Jul-87 13:01:12 EDT Article-I.D.: nbires.1206 Posted: Thu Jul 9 13:01:12 1987 Date-Received: Sun, 12-Jul-87 07:06:27 EDT References: <176@titn.TITN> Reply-To: maa@nbires.UUCP (Mark Armbrust) Organization: NBI Inc, Boulder CO Lines: 43 Summary: Get/Set Process ID In article <176@titn.TITN> jordan@titn.TITN (Jordan Bortz) writes: >Hello - we have a background process under DOS, which: > > 1) Terminates And Stays Resident > 2) Chains Off The Timer Interrupt To Run > 3) Reads Info From A Modem Line And Writes It To Disk > >We are having problems with 3) -- sometimes it works, sometimes it crashes. >We have tried looking at the DOS busy flag and appear to do the right thing, >but it still fails intermittantly. If you are using MSDOS file I/O to write to the disk, you need to make sure that your Process ID (PID) is the same for all MSDOS file calls. There are two undocumented MSDOS calls to support this. [I found them by snooping in DEBUG; sort of recursive debugging?] Function 50h: Set Process ID -- Set the PID for the executing process. mov bx, NEW_PID mov ah, 50h int 21h Function 51h: Get Process ID -- Get the PID of the executing process. mov ah, 51h int 21h ; PID returned in BX On MSDOS 2.11 and 3.2 [the only versions I use] the PID has the same value as the Program Segment Prefix (PSP). Microsoft added and documented Function 62h: "Get PSP" in MSDOS 3.X. I don't know about other versions, but in 3.2 functions 51 and 62 execute the same code. [I guess MS did't want to admit that there really was an easy way for a .EXE program to find its PSP. Also, 3.X documented function 58h is available in 2.11. Ain't politics wonderful! 8-)# ] The general idea is to swap to your PID, do the MSDOS operations, and then swap back to it PID of the interrupted process. Hope this helps. Mark Armbrust