home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4343 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  1.4 KB

  1. Xref: sparky comp.os.os2.programmer:4343 comp.lang.c:12559
  2. Newsgroups: comp.os.os2.programmer,comp.lang.c
  3. Path: sparky!uunet!mcsun!ieunet!wsl!jja
  4. From: jja@wsl.ie (John J. Allen)
  5. Subject: Re: malloc causes a segmentation violation!?
  6. Message-ID: <1992Aug20.092700.8373@wsl.ie>
  7. Organization: Project Papyrus, AIRAID, Dublin, Ireland
  8. References: <harris.714243433@garfield.catt.ncsu.edu>
  9. Date: Thu, 20 Aug 1992 09:27:00 GMT
  10. Lines: 25
  11.  
  12. harris@garfield.catt.ncsu.edu (Michael Harris) writes:
  13. : mn87504@cs.tut.fi (Naatula Mika) writes:
  14. : >I thought that OS/2 could detect writes to non-allocated areas and
  15. : >give me a segmentation fault right away.  Like it usually does. 
  16. : What you have to understand is that the area IS allocated as far as the
  17. : operating system is concerned.  It is allocated to your process.  Since your
  18. : process owns it, the operating system is very happy to let you write there.
  19. : Memory protection in OS/2 protects one process from another... not a process
  20. : from itself.
  21.  
  22. OS/2 2.0 = Flat memory model
  23. OS/2 1.x = Segmented memory model.
  24.  
  25. The segmented memory model had some advantages over the flat model. If I
  26. used DosAllocSeg() to create a 20k block and then ran off the end of
  27. it I'd get a segmentation violation as soon as I did that. (As in Win 3.x)
  28.  
  29. So although the FLAT memory model simplifies programming it hampers
  30. debugging.
  31.  
  32. Well as they say "You can't have your cake and eat it too"
  33.  
  34.