chryses@quiche.cs.mcgill.ca (Phong CO) (09/25/89)
Hi, I am new to the net and have a couple of questions to ask: 1) I have Windows/286 2.11, and the Software Developement Kit. I tried to compile the Generic program under the large module. I changed the makefile by adding the -AL switch to the MSC 5.1, and changed the library from slibw to llibw. I also added a menu to the resource file. The pro- gram compiles and runs fine, except that the menu does not show up. It does show up if I return to the small model. Is there something else I should modify or include somewhere? 2) I want to write a program that will, at startup, allocate a (very) large block of memory, say about 4MB. I intend to use this as a heap, and have my own heap management functions. The block will be locked as soon as it is allocated, and unlocked when the program terminates. The fact that I won't be able to run anything else in the meantime is not a problem. The problem is that GlobalAlloc fails with that amount. Microsoft Tech Support claims that data size depends on extended memory size, since data segments are not swapped. I currently have 2MB of extended memory on my AT, most of which has been given to SMARTdrv. Is there a way to manage this block of memory? E-mail responses will be fine. Thank you very much. I'll work on my .signature someday. Phong Co chryses@quiche.mcgill.ca
roberth@microsoft.UUCP (Robert Hess) (09/29/89)
Phong, (he had a couple questions about writing a Windows program that used LARGE memory model...) First off, a comment on using the LARGE memory model... *** DON'T *** I have yet to see a program that actually needs to use the LARGE memory model (and I've seen a lot of programs). I'm sure many of you will agree that Aldus PageMaker is a rather large application, and has some pretty awsome data and code demends. It uses MEDIUM model. I can't count the number of times that a developer has tried to convince me that they needed to use the LARGE memory model, yet I easily showed them how they could not only use MEDIUM, but get their program running faster, and more optimumly as well. When you 'own' the CPU, the LARGE model can make sense. You KNOW exactly what is being done when, and by who. (You control the Horizontal, You control the Vertical...) In Windows, you are not in control of what code is running, or where it is running from. You don't know when data swapping is needed, you don't know where it is going to be swapped to, and you don't know what other operations the user is trying to accomplish. Hopefully I have gotten my point across without needing to bring out a 2x4, now to your questions: > 1) I have Windows/286 2.11, and the Software Developement Kit. I tried > to compile the Generic program under the large module. I changed the > makefile by adding the -AL switch to the MSC 5.1, and changed the > library from slibw to llibw. I also added a menu to the resource file. > The pro- gram compiles and runs fine, except that the menu does not show > up. It does show up if I return to the small model. Is there something > else I should modify or include somewhere? Unfortunately, my system is no longer set up to compile Windows, and I have not tried to do this myself (for good reasons), so I can only give you a guess. Your stack is too small. This is just one of the MANY problems that you will come across when trying to use the LARGE memory model. > 2) I want to write a program that will, at startup, allocate a (very) > large block of memory, say about 4MB. I intend to use this as a heap, > and have my own heap management functions. The block will be locked as > soon as it is allocated, and unlocked when the program terminates. The > fact that I won't be able to run anything else in the meantime is not a > problem. The problem is that GlobalAlloc fails with that amount. > Microsoft Tech Support claims that data size depends on extended memory > size, since data segments are not swapped. I currently have 2MB of > extended memory on my AT, most of which has been given to SMARTdrv. Is > there a way to manage this block of memory? Am I missing something here, are are you asking how to allocate 4mb of memory on a machine that doesn't even have 2mb available? How much free memory does GlobalCompact tell you is available? There is no way that GlobalAlloc will allow you to access more memory then that. Even on a Large Mainframe computer, it is rarely adviseable to simply allocate that large of a chunk of memory and just 'use' it. It is always preferable to use some sort of memory blocking algorithm to contain your memory in smaller segments. You will be using smaller addressing, thus faster access, you will only be allocating/initializing the memory as the user is needing it, thus increasing the apparent speed of the program. And depending on your method, you will also be safer in case of a system failure, because you may be storing your temporary data in a virtual memory file on disk. If you *MUST* use LARGE memory model, first go see a shrink, then talk your school into getting a Microsoft OnLine account (=~$800). You will need to get direct support from Microsoft to help you identify and work around the problems that you will encounter. I know that there are several other universities that have accounts (maybe yours already has one). -Robert __________________________________________________________________________ ##### ####### | Robert B. Hess, Microsoft Corp., Redmond, WA ###### ####### |----------------------------------------------------- ####### ####### | roberth@microsof.uu.net #### ##### #### | {decvax, uunet, uw-beaver}!microsof!roberth #### ### #### |_____________________________________________________ "...my opinions are strictly my own, and not those of my employer..."
jack@csccat.UUCP (Jack Hudler) (09/30/89)
In article <7887@microsoft.UUCP> roberth@microsoft.UUCP (Robert Hess) writes: > > >Phong, > >(he had a couple questions about writing a Windows program that used >LARGE memory model...) > >First off, a comment on using the LARGE memory model... > > *** DON'T *** > >I have yet to see a program that actually needs to use the LARGE memory >model (and I've seen a lot of programs). I'm sure many of you will agree >that Aldus PageMaker is a rather large application, and has some pretty >awsome data and code demends. It uses MEDIUM model. > >I can't count the number of times that a developer has tried to convince >me that they needed to use the LARGE memory model, yet I easily showed >them how they could not only use MEDIUM, but get their program running >faster, and more optimumly as well. > If you use th multi-threaded library in OS/2.. it's the only Model you can use! LARGE! -- Jack Computer Support Corportion Dallas,Texas Hudler UUCP: {texsun,texbell,attctc}!csccat!jack
bturner@hpcvlx.cv.hp.com (Bill Turner) (10/02/89)
> If you use th multi-threaded library in OS/2.. it's the only Model you > can use! LARGE! The problem isn't in OS/2, but rather in MSW on DOS. I have a bit of understanding on the way MSW handles memory (if you are curios, I believe Petzold has a pretty good description), and you really cannot use LARGE model in MSW. A lot of this has to do with how multiple instances of movable data segments are handled. [The real problem is that MSW is trying to do memory management in software without hardware support. The curse of living in the DOS/8086 real-mode world.] --Bill Turner (bturner@hp-pcd.hp.com) HP Corvallis Information Systems
michaelt@microsoft.UUCP (Michael Thurlkill 1/1029) (10/04/89)
In article <1464@quiche.cs.mcgill.ca> chryses@quiche.cs.mcgill.ca (Phong CO) writes: >Hi, I am new to the net and have a couple of questions to ask: > >1) I have Windows/286 2.11, and the Software Developement Kit. I tried >to compile the Generic program under the large module. I changed the ... As mentioned by a few other people, this is not recommended. There are few instances where you HAVE to use large model. By using medium model, you will be able to have multiple code segments, but only one data segment. However, you can GlobalAlloc additional blocks of memory as needed. This is what PageMaker, Excel, Designer, etc. etc. do. If you are starting an application, it is to your advantage to start with medium model. The one case I have seen where it is valid to use large model, is when converting an existing large model app. It is advantageos to eventually convert to medium model, but you can get things working initially in large model. The basic requirements are: make all data segments FIXED, and increase the stack size (doubling is a safe bet). Since large model makes all data references FAR, the reference is resolved at load time. If the data moves, the reference is invalid, but doesn't get fixed up. Thus the fixed requirement. The stack must be larger because pointers and other data items are larger. Expect performance to be severly degraded if you go with large model. Since you have many fixed memory objects, it is harder for Windows to move memory around to fullfill allocation requests, so it takes more time. > >2) I want to write a program that will, at startup, allocate a (very) >large block of memory, say about 4MB. I intend to use this as a heap, >and have my own heap management functions. The block will be locked as >soon as it is allocated, and unlocked when the program terminates. The >fact that I won't be able to run anything else in the meantime is not a >problem. The problem is that GlobalAlloc fails with that amount. >Microsoft Tech Support claims that data size depends on extended memory >size, since data segments are not swapped. I currently have 2MB of >extended memory on my AT, most of which has been given to SMARTdrv. Is >there a way to manage this block of memory? > Under the current version of Windows, you are constrained to the 640k conventional memory space. If you are using expanded memory (or virtualizing extended memory as expanded), code and data will be banked to expanded memory, but each application will have access to at most 640k. Therefore, you can run multiple applications to consume your 2MB of extended, but your application will be able to GlobalAlloc a maximum of probably 200-400k. As mentioned by another person, you should try to break up your data in order to better utilize memory. You still have the same allocation limit though. If you MUST allocate a larger amount than you can get via GlobalAlloc, you may want to look into making direct expanded memory calls. You can only make LIM 3.2 calls in a Windows application, and the app must be RCed with the -L switch. You can find information on the LIM api in the MS-DOS Encyclopedia, and various other references. Since you only have 2MB of memory, you still won't be able to allocate 4MB of memory. Oh yeah, remember that if you GlobalAlloc a block larger that 64k, it should be fixed, and should be accessed with a HUGE pointer. Mike Disclaimer: These thoughts and opinions are my own. They should not be mis-construed to be correct or in any way related to my employer.
caa@garnet.ssd.cdc.com (Charles A. Anderson) (10/05/89)
michaelt@microsoft.UUCP (Michael Thurlkill 1/1029) writes: |In article <1464@quiche.cs.mcgill.ca> chryses@quiche.cs.mcgill.ca (Phong CO) writes: |>Hi, I am new to the net and have a couple of questions to ask: |> |>1) I have Windows/286 2.11, and the Software Developement Kit. I tried |>to compile the Generic program under the large module. I changed the |... |As mentioned by a few other people, this is not recommended. There are |few instances where you HAVE to use large model. Tell me about it calling up the Microsoft helpline and telling people I needed help with a large model application I'd get responses like: You have a large model application....and it works.... |> |to look into making direct expanded memory calls. You can only make |LIM 3.2 calls in a Windows application, and the app must be RCed with |the -L switch. You can find information on the LIM api in the I thought windows needed LIM 4.0, we had 3.2 drivers for the machines that we were devloping on and they wouldn't work. -Charlie |Mike --- Charles Anderson | caa@garnet.ssd.cdc.com \ Disclaimer: I said what? ----------------/ caa@midgard.mn.org \ But CDC didn't. I woke up this morning and it was nice out, so I left it out. -- Charles Anderson | caa@garnet.ssd.cdc.com \ Disclaimer: I said what? ----------------/ caa@midgard.mn.org \ But CDC didn't. I woke up this morning and it was nice out, so I left it out.
goof@quiche.cs.mcgill.ca (Paul LOSORDO) (10/13/89)
Hi, quick question for you gurus: How do I get the current position of the cursor within an edit control? I need the offset in characters from the beginning of the buffer. thanx
tomer@rainbow.wbst128.xerox.com (Shmuel Tomer) (10/17/89)
In article <7887@microsoft.UUCP> roberth@microsoft.UUCP (Robert Hess) writes: > >First off, a comment on using the LARGE memory model... > > *** DON'T *** If you don't use the LARGE memory model, and if you use GlobalAlloc to get additional memory, is there any way you could call C library functions (eg, strcmp, sprintf), using data from that additional memory? Do you have to re-implement any such function? I seem to remember that one of the sample programs in the SDK does implement strcmp with mixed NEAR / FAR arguments. This is easy, though probably inefficient, but re-implementing sprintf may not be exactly where one wants to spend one's time. Shmuel Tomer Tomer.wbst@Xerox.COM
press@venice.SEDD.TRW.COM (Barry Press) (10/18/89)
In article <246@spot.wbst128.xerox.com> Tomer.wbst@Xerox.COM (Shmuel Tomer) writes: >If you don't use the LARGE memory model, and if you use GlobalAlloc to get >additional memory, is there any way you could call C library functions (eg, >strcmp, sprintf), using data from that additional memory? Do you have to >re-implement any such function? I seem to remember that one of the sample >programs in the SDK does implement strcmp with mixed NEAR / FAR arguments. >This is easy, though probably inefficient, but re-implementing sprintf may >not be exactly where one wants to spend one's time. You can do string and some other things using some undocumented functions in the Windows kernel. See Petzold's excellent book on Programming Windows for more info. You can feed mixed arguments to sprintf using the modifiers that specify near and far addressing -- see the printf documentation. The thing you can't do directly is feed sprintf a buffer which has the wrong address size (but you can do the work to a temporary area and then copy if you must). Barry Press *Of course these are my opinions; when someone else wants my opinion, they *give it to me.
kyler@pyr.gatech.EDU (J. Kyle Rogers) (10/21/89)
In article <82@venice.SEDD.TRW.COM> press@venice.sedd.trw.com (Barry Press) writes: >In article <246@spot.wbst128.xerox.com> Tomer.wbst@Xerox.COM (Shmuel Tomer) writes: >>[...] is there any way you could call C library functions (eg, >>strcmp, sprintf), using data from that additional memory? Do you have to >>re-implement any such function? [...] >You can do string and some other things using some undocumented functions >in the Windows kernel. Is it true that these functions are no longer present in Windows 3.0? >You can feed mixed arguments to sprintf using the modifiers >that specify near and far addressing -- see the printf documentation. >Barry Press I seem to remember a difference between the specification strings for sprintf in the MSC 5.1 standard library and the sprintf in the Windows library. I may be wrong about that, but in medium model I routinely use a call like the following, which works fine. sprintf (szBuffer, "Local String = %s Global String = %Fs", szLocalString, lpszGlobalString); Here, the 'F' is a modifier telling sprintf to expect a FAR pointer; I believe there is also a modifier 'N' to tell sprintf to expect a NEAR pointer, but that is the default anyway in medium model. | krogers -- J. Kyle Rogers -- P.O. Box 31467 | | Georgia Insitute of Technology, Atlanta Georgia, 30332 | |uucp: ...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!kyler| |ARPA: kyler@pyr.gatech.edu |