kiely@lownlab.harvard.edu (James P. Kiely) (05/19/89)
I am trying to figure out how one determines how much memory is available to a process, including that allocated to the process and that which could be allocated with "setblock" (int 21, func 4Ah), in DOS. I have a number of questions: 1) What is the word at offset 2 of the PSP really? According to Norton: ".. tells how much memory is available by listing the segment-paragraph address of the end of DOS memory. Multiplying this number by 16 [decimal] gives the total bytes that DOS considers usable. The DOS command CHKDSK reports the same amount. ..." After considerable finagling I have determined that this is the "Total Memory" field of CHKDSK not the "Free Memory" field. On my machine, an AT clone running PC-DOS 3.20, it is always A000h. Is there an easy way to get the "Free Memory" field? 2) In every book I have ever seen, they are very emphatic that a user process should not change any part of the PSP below offset 4Ch. The startup code for MicroSoft C (crt0.o , astart:) modifies offset 2 of the PSP. Why does MicroSoft C do this seemingly illegal behavior and is it indeed illegal? And what is the word at offset 2 of the PSP after astart: modifies it? 3) What is the correct way to determine how much core is available to a process? 4) What is the correct way to determine how much memory is available in the far heap? 5) Is the far/near heap a DOS concept or a MicroSoft C concept? Please respond via email. I will summarize responses to the net. Thanks. ============================================================================= NAME: James P. Kiely USPS: Kiely Laboratories USENET: ...!harvard!lownlab!kiely P.O. Box 624 DOMAIN: kiely@lownlab.harvard.edu Allston, MA 02134-0624 PHONE: +1 617 782 4136 USA
dmt@mtunb.ATT.COM (Dave Tutelman) (05/19/89)
In article <1875@husc6.harvard.edu> kiely@lownlab.harvard.edu (James P. Kiely) writes: > >2) In every book I have ever seen, they are very emphatic that a user >process should not change any part of the PSP below offset 4Ch. >The startup code for MicroSoft C (crt0.o , astart:) modifies offset >2 of the PSP. Why does MicroSoft C do this seemingly illegal behavior >and is it indeed illegal?... Because MicroSoft wrote the rules for you, not for themselves :-( Seriously, folks, Microsoft is probably the single biggest violator of the MSDOS rules and programming practices. My job once included some really gut-level system programming in the DOS environment, and our test suite of ill-behaved programs was more than 50% Microsoft. Nobody does as much with their applications to take advantage of the internal implementation of the OS (and even the hardware). Consequently, nobody has as serious problems porting their applications from release to release, nor such problems running their applications on not-quite-clones. (Actually, ALMOST nobody. After all, they are one company, and the applications and OS folks do get a chance to talk to one another before releasing the product.) +---------------------------------------------------------------+ | Dave Tutelman | | Physical - AT&T Bell Labs - Middletown, NJ | | Logical - ...att!mtunb!dmt | | Audible - (201) 957 6583 | +---------------------------------------------------------------+ The opinions herein are mine, not my employer's.