Thunk (pronounced thunk)
(1) Onomatopoeic slang for
sounds such as the impressive thud when the doors close on pre-modern
Mercedes-Benz; representing the dull sound of the impact of a heavy object
striking another and coming to an immediate standstill, with neither object
being broken by the impact.
(2) In computer programming, a delayed computation (known
also as a closure routine.
(3) In computing, in the Scheme programming language, a
function or procedure taking no arguments.
(4) In computing, a specialized subroutine in operating
systems where one software module is used to execute code in another or inject
an additional calculation into another subroutine; a mapping of machine data
from one system-specific form to another, usually for compatibility reasons, to
allow a 16-bit program to run on a 32-bit operating system.
(5) In computing, to execute code by means of a thunk.
(6) As “get thunked” or “go thunk yourself”, an affectionate
insult among the nerdiest of programmers.
(7) In colloquial use, a past tense form of think (the standard form being "thought"). Usually it's used humorously but, if erroneous, it's polite not to correct the mistake.
Getting thunked
Thunking as a programming concept does seem to have been invented in 1961 as “a chunk of code which provides an address”, a way of binding parameters to their formal definitions in procedure calls. If a procedure is called with an expression in the place of a formal parameter, the compiler generates a thunk which computes the expression and leaves the address of the result in some standard location. It usefulness was such it was soon generalised into: an expression, frozen with its environment for later evaluation if and when needed (that point being the closure), the process of unfreezing thunks called forcing. As operating systems evolved into overlay-rich environments, the thunk became a vital stub-routine to load and jump to the correct overlay, Microsoft and IBM both defining the mapping of the 16-bit Intel environment with segment registers and 64K address limits whereas 32 & 64-bit systems had flat addressing and semi-real memory management. Thunking permits multiple environments to run on the same computer and operating system and to achieve this, there’s the universal thunk, the generic thunk and the flat thunk, the fine distinctions of which only programmers get. In another example of nerd humor, a person can be said to have their activities scheduled in a thunk-like manner, the idea being they need “frequently to be forced to completion”, especially if the task is boring.
Lindsay Lohan and her lawyer in court, Los Angeles, December 2011.
So it’s a bit nerdy but modern operating systems need
thunking because 8, 16, 32 and 64-bit routines can need to run both
concurrently and interactively on the same machine (real or virtual). If a 32-bit application sends something with precision
data types to a 64-bit handler, without thunking, the call will fail because
the precise address can’t be resolved.
Although not literally true, it’s easiest to visualise thunking as a
translation layer.
Thunking first entered consumer computing at scale with IBM’s OS/2 in 1987, an operating system still in surprisingly wide use and supported by IBM until early in the century. Interestingly, although both OS/2 (and its successor eCom) have been unavailable for years, in August 2017, a private project released ArcaOS, an x86 operating system derived from OS/2 and, for personal use, it retails at US$129.00. Like OS/2, it has some features which are truly unique such as, for the handful of souls on the planet who either need or wish simultaneously to run multiple 8, 16 and 32-bit text-mode sessions, (including those internally booting different operating systems in segregated memory) in their hundreds on the one physical machine. First done in 1992 on OS/2 2.0, it’s still quite a trick and the on-line OS/2 Museum hosts an active community, development continuing.
No comments:
Post a Comment