Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!uunet!microsoft!kevinro From: kevinro@microsoft.UUCP (Kevin ROSS) Newsgroups: comp.os.os2 Subject: Re: overlays in 32-bit OS/2 Keywords: Virtual Memory 80386 Message-ID: <54378@microsoft.UUCP> Date: 30 Apr 90 20:24:21 GMT References: <1990Apr27.155908.4260@geac.com> <273@caslon.cs.arizona.edu> <4401@plains.UUCP> Reply-To: kevinro@microsoft.UUCP (Kevin ROSS) Organization: Microsoft Corp., Redmond WA Lines: 67 In article <4401@plains.UUCP> harlow@plains.UUCP (Jay B. Harlow) writes: >In article <273@caslon.cs.arizona.edu> roussos@cs.arizona.edu (George E. Roussos) writes: >>In article <1990Apr27.155908.4260@geac.com> mike@geac.com (Mike Sweet) writes: ||| I'm currently using OS/2 version 1.1 and managing to acieve code ||| overlays with DosCreateCSAlias. ||| [stuff deleted - how will this work on 32 bit OS/2]. ||| Anyone know the answer to this? (i.e. can I read code off the disc ||| into a piece of memory and then jump into it) [in 32 bit OS/2] ? Why the need for code overlays? If you are creating code on the fly, then DosCreateCSAlias will work. However, there is no such 32-bit function under OS/2 v2.0. The 16-bit version of the API will still work under 2.0. ||Someone please correct me if I am wrong, but in theory if a program is ||running under an OS that takes advantage of the 386 architecture, it ||does not need an overlay scheme to use code that can't be loaded into ||memory at run time. This is thanks to the built in hardware support ||for virtual memory in the 386. |Have you used OS/2 & the DosCreateCSAlias system call????. | |the DosCreateCSAlias is used to create an excutable alias to a data |segment, For it is bad 'karma' to go executing DATA (good sign of a |bug in your program). Now you have this routine that compiles a |'language' on the fly (imcremental compiling, speadsheets, graphing...) |that you have NO IDEA what the functions are going to be until |the user is running you program (god knows where & why). Executing a DATA segment isn't just bad Karma, it is not possible. CODE segments are all executable. You cannot write to them. DATA segments are marked as read/write, and cannot be executed. This is enforced by the chip. |yes OS/2 2.0 is suppose to use PAGED V.M. as oppose to SEGMENTED V.M. & |only support a 'flat'? 32bit address space (not sure if seperate I&D), |if you have seperate I&D, then you need to alias, because a data |address is different from a inst address in seperate I&D The I&D space is the same. Under v2.0, if you want to have the same functionallity as DosCreateCSAlias, then you would use the following constructs: ... // Make a variable for the function address (void * pfnAddr)(); // Allocate a region to create the code in. DosAllocMem(&(void *)pfnAddr,ulSize,PAG_READ|PAG_WRITE|PAG_COMMIT); // Call some routine that writes code into your region CreateSomeCodeFunction(pfnAddr); // Setup the memory as executable DosSetMem(pfnAddr,ulSize,PAG_EXECUTE); // Call your function pfnAddr(); I have never actually tried this, but it should work.