What Isa Thunk

What is a "Thunk?"

There seem to be several alternate definitions of the term:


I like to think of a thunk as a very small routine for calling another routine. This encompasses CallByName thunks as well as (I think) the 16/32-bit calls. Routines that are basically wrappers for another, but with less parameters (providing defaults), would also be thunks under this definition. It's probably not what most people would call it, but it works for me! -- MatthewTuck

[16/32-bit calls would be ThunkToaDifferentAddressSpace.]

Along these lines JamieZawinski uses "thunk" to refer to the parts of XScreenSaver code that implement XLib in terms of OS X Cocoa graphics, or that implement a OpenGL 1.5 in terms of OpenGL ES 2.0.


(v) In PCs, to convert a 16-bit memory address to a 32-bit address, and vice versa. Thunking is necessary because Intel's older 16-bit microprocessors used an addressing scheme called segmented memory, whereas their new 32-bit microprocessors use a flat address space . Windows 95 supports a thunk mechanism to enable 32-bit programs to call 16-bit DLLs. This is called a flat thunk. On the other hand, 16-bit applications running under Windows 3.x and Windows for Workgroups cannot use 32-bit DLLs unless the 32-bit addresses are converted to 16-bit addresses. This is the function of Win32s, and is called a universal thunk.

According to folklore, the term thunk was coined by the developers of the Algol-60 programming language, who realized late one night that the data type of parameters could be known with a little forethought by the compiler. That is, by the time the compiler processed the parameters, it had already thought (or thunk) of the data types. The meaning of the term has changed considerably in recent years.

http://aol.pcwebopedia.com/TERM/t/thunk.html


When I asked this question of a MS guru during my visit to "Greater Redmond" in 1987 (OS/2 Developer's Convention), he replied that it was "imitative of the sound of a transmission, shifting from a high gear to low abruptly" and could be used to describe calls between 16-bit and 32-bit spaces, the method used to reset the 80286 on-the-fly to get from protected mode back to real mode under OS/2, and other interfaces of this kind, used to bridge essentially incompatible modes or spaces.


CategoryDefinition


EditText of this page (last edited November 6, 2012) or FindPage with title or text search