ALERT

[FREE DEMO] Deploy Your Enterprise Cloud in Minutes

Thunk

Definition - What does Thunk mean?

A thunk, in a general computing context, is a piece of low-level machine generated code, which implements the details of a software system. It is one of the following:

  1. A piece of code performing a delayed computation
  2. A feature of a virtual function table implementation
  3. A mapping of machine data from one system specific form to another for compatibility issues

Techopedia explains Thunk

The concepts of thunk emerged in early 1961. It is a computation returning a value of the argument when executed. A call by need replaces a thunk by its return value after the first execution. Languages with late binding have lookup in run time, based on computations performed by thunk.

Nullary functions (functions which do not take arguments) in functional programming are referred to as thunk. Thunks simulate lazy evaluation and delay the function argument computation. These functions further force thunks to get actual values. Thunk may also appear naturally in the implementation of constant functions in high order programming.

Compilers of object oriented languages such as C++ generate functions termed thunks. They optimize virtual function calls in the presence of virtual or multiple inheritances.

Some instances of relocatable code use local thunks to call library functions. Dynamic library call in the code jumps to thunks in a jump table, which is further replaced by functions loading the applicable library or moves to a suitable point in an already loaded library. So a thunk in this area computes or returns previously computed and cached values. Thunks are used in software based virtual memory systems to perform a mapping from virtual to physical address. Creating a 16-bit virtual DOS machine inside a 32-bit OS is called thunking and ensures a backward compatibility with applications using old system calls.

Flat thunks use thunks translating calls from 32-bit code to 16-bit code. An intermediate code translates memory address between platforms. Microsoft has a thunking layer of itself called Win32s, which permit 32-bit Windows application to run on 16-bit Windows. The 64-bit Windows version also provides a thunking layer, WoW64, which permits using 32-bit Windows applications.

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
"Techopedia" on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Resources
The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.