²é¿´: 397  |  »Ø¸´: 0
µ±Ç°Ö÷ÌâÒѾ­´æµµ¡£

sdlj8051

½ð³æ (ÖøÃûдÊÖ)

[½»Á÷] [zt]¾­³£¼ûµÄthunkµÄ½âÊÍ

ÏÂÃæÊǶ¨Ò壺
thunk
In a PC, to execute the instructions required to switch between segmented addressing of memory and flat addressing. A thunk typically occurs when a 16-bit application is running in a 32-bit address space, and its 16-bit segmented address must be converted into a full 32-bit flat address. On the other hand, if a 32-bit program calls a 16-bit DLL, then the thunk is in the opposite direction: from 32 bit to 16 bit.
ÔÚµçÄÔÀΪÁËÖ´ÐÐÖ¸ÁÐèÒªÔÚÄÚ´æ¶ÎµØÖ·ºÍƽ̹µØÖ·Ö®¼ä½øÐÐת»»¡£µ±16λӦÓóÌÐòÔÚ32λµØÖ·¿Õ¼ä½øÐÐÔËÐеÄʱºò£¬Ó¦ÓóÌÐòµÄ16λ¶ÎµØÖ·±ØÐëת»¯³É32λƽ̹µØÖ·£¬ÕâʱºòthunkÊǺÜÈÝÒ×¼ûµ½µÄ¡£ÁíÍ⣬Èç¹ûÒ»¸ö32λ³ÌÐòºô½ÐÒ»¸ö16λDLL£¬ÄÇôthunk¾Í´æÔÚÓÚÏà·´µÄ·½Ïò£º´Ó32λת±ä³É16λ¡£


Ïà¹ØµÄÀúÊ·£º
thunk

1. [obs.]¡°A piece of coding which provides an address:¡±, according to P. Z. Ingerman, who invented thunks in 1961 as a way of binding actual parameters to their formal definitions in Algol-60 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.

"Ö»ÊDZàд¿ÉÌṩµØÖ·µÄ´úÂëµÄÒ»²¿·Ö£º¡±£¬P.Z.IngermanÈçÊÇ˵¡£ËûÊÇÔÚ1961Äê·¢Ã÷Õâ¸ö¶¨ÒåµÄ¡£µ±Ê±ÊǶ¨ÒåÕâÑùÒ»¸ö·½·¨£º°Ñʵ¼Ê²ÎÊý°ó¶¨µ½ÔÚAlgol-60³ÌÐòÀïºô½Ðµ½µÄ¶¨Òå¡£Èç¹ûÒ»¸ö³ÌÐòÔÚ±»ºô½ÐµÄʱºò£¬ÓÃÒ»¸ö±í´ïʽռ¾ÝÁËÐβεÄλÖã¬ÄÇô±àÒëÆ÷¾Í»á²úÉúÒ»¸öthunk£¬Õâ¸öthunkÖ¸µÄÊÇ£º¼ÆËã±í´ïʽµÄµØÖ·£¬È»ºó°ÑÕâ¸öµØÖ··ÅÔÚÊÊÒ˵ÄλÖá£

2. Later generalized into: an expression, frozen together with its environment, for later evaluation if and when needed (similar to what in techspeak is called a closure). The process of unfreezing these thunks is called forcing.

¹ýÁ˲»¾Ã£¬ËüµÄÒâ˼¾ÍÀ©´óÁË£ºÒ»¸ö±í´ïʽ£¬±»ËüËùÔڵĻ·¾³ËùÏÞÖÆ£¬ÔÚÐèÒªµÄʱºòÖØÐ¼ÆËãÕâ¸ö±í´ïʽµÄÖµ£¨ÓеãÏótechspeakÀïµÄclosure£¨¹ØÓÚclosure²Î¿¼ÏÂÃæ¡££©£©¡£Íê³ÉÕâЩthunksµÄ¹ý³Ì¾Í³ÆÎªforcing¡££¨Ê²Ã´¶«¶«£¿Ç¿ÆÈ£¿±©Á¦£¿ÍûÖ¸½Ì£©

3. A stubroutine, in an overlay programming environment, that loads and jumps to the correct overlay. Compare trampoline.

stubroutine£¨stub subroutineµÄËõд£¬ÊÇsubroutine£¨²Î¿¼ºóÎÄ£©µÄռλ·û£¬Í¨³£ºÜС£¬»òÕßΪ¿Õ£¬ÔÚºóÀ´±»³äʵ£©£¬Í¨³£´æÔÚÓÚÍâ¿Ç±à³Ì»·¾³£¬Ëü×°ÔØ²¢Ìø×ªµ½ÕýÈ·µÄÍâ¿Ç¡£ºÃ±È±Ä´²¡£

4. Microsoft and IBM have both defined, in their Intel-based systems, a ¡°16-bit environment¡± (with bletcherous segment registers and 64K address limits) and a ¡°32-bit environment¡± (with flat addressing and semi-real memory management). The two environments can both be running on the same computer and OS (thanks to what is called, in the Microsoft world, WOW which stands for Windows On Windows). MS and IBM have both decided that the process of getting from 16- to 32-bit and vice versa is called a ¡°thunk¡±; for Windows 95, there is even a tool THUNK.EXE called a ¡°thunk compiler¡±.

MicrosoftºÍIBM¶ÔËü¶¼½øÐÐÁ˶¨Ò壬ÔÚ»ùÓÚIntelµÄϵͳÀһ¸ö¡°16λ»·¾³¡±£¨Ê¹ÓÃbletcherousµÄ¶Î¼Ä´æÆ÷£¬²¢ÇÒÓÐ64KµØÖ·µÄÏÞÖÆ£©ºÍÒ»¸ö¡°32λ»·¾³¡±£¨Ê¹ÓÃÆ½Ì¹µØÖ·£¬²¢ÇÒʵÏÖ°ëÕæÊµÄÚ´æ¹ÜÀí¹¦ÄÜ£©¡£ÕâÁ½¸ö»·¾³¶¼ÄÜÔÚͬÑùµÄµçÄÔºÍOS£¨¹ËÃû˼Ò壬ÔÚMicrosoftµÄÊÀ½ç£¬WOWÖ¸µÄÊÇWindows On Windows£©¡£MSºÍIBM¶¼¾ö¶¨°Ñ£­£­£­´Ó16λµ½32λºÍ32λµ½16λµÄת±ä£­£­£­½Ð×ö¡°thunk¡±£»
¾ÍWindows 95¶øÑÔ£¬ÉõÖÁ»¹ÓÐÒ»¸ö¹¤¾ßTHUNK.EXE±»³ÆÎª¡°thunk±àÒëÆ÷¡±¡£

5. A person or activity scheduled in a thunklike manner. ¡°It occurred to me the other day that I am rather accurately modeled by a thunk ¡ª I frequently need to be forced to completion.:¡± ¡ª paraphrased from a plan file.

Historical note: There are a couple of onomatopoeic myths circulating about the origin of this term. The most common is that it is the sound made by data hitting the stack; another holds that the sound is that of the data hitting an accumulator. Yet another suggests that it is the sound of the expression being unfrozen at argument-evaluation time. In fact, according to the inventors, it was coined after they realized (in the wee hours after hours of discussion) that the type of an argument in Algol-60 could be figured out in advance with a little compile-time thought, simplifying the evaluation machinery. In other words, it had ¡®already been thought of¡¯; thus it was christened a thunk, which is ¡°the past tense of ¡®think¡¯ at two in the morning¡±.




closure
In programming languages, a closure is a function that refers to free variables in its lexical context.
ÔÚ³ÌÐòÉè¼ÆÀclosureÊÇÒ»¸öº¯Êý¡£Õâ¸öº¯ÊýÔÚÆäÉÏÏÂÎÄÖÐÉæ¼°µ½ÁËÊͷűäÁ¿¡£

A closure is usually a function created by a program at run time. This is best demonstrated by a function that appears entirely within the body of another function. The nested, inner function must refer to local variables of the outer function. As the outer function executes, it creates a new instance of the inner function. If that inner function refers to some of the local variables of the outer function, a closure is formed. It consists of the function code and a reference to any variables in the outer function's scope that the closure needs.

Closures are commonly used in functional programming to defer calculation, to hide state, and as arguments to higher-order functions.




Several object-oriented techniques and language features simulate some features of closures. For example:

In [[C++]], programmers may define function objects by overloading operator(). These objects behave somewhat like functions in a functional programming language. They may be created at runtime and may contain state. However, they do not implicitly capture local variables as closures do. Two proposals to introduce C++ language support for closures (both proposals call them lambda functions) are being considered by the C++ Standards Committee [1], [2]. The main difference between these proposals is that one stores a copy of all the local variables in a closure by default, and another stores references to original variables. Both provide functionality to override the default behaviour. If some form of these proposals is accepted, one would be able to write
void foo(string myname) {
   typedef vector names;
   int y;
   names n;
   // ...
   names::iterator i =
     find_if(n.begin(), n.end(), <>(const string& s){return s != myname && s.size() > y;});
   // i is now either n.end() or points to the first string in n
   // which is not equal to  myname and which length is greater than y
}
Java allows the programmer to define "anonymous classes" inside a method; an anonymous class may refer to names in lexically enclosing classes, or final variables in the lexically enclosing method.
class CalculationWindow extends JFrame {
     private JButton btnSave;
     ...

     public final calculateInSeparateThread(final URI uri) {
         // The expression "new Runnable() { ... }" is an anonymous class.
         Runnable runner = new Runnable() {
                 void run() {
                     // It can access final local variables:
                     calculate(uri);
                     // It can access private fields of the enclosing class:
                     btnSave.setEnabled(true);
                 }
             };
         new Thread(runner).start();
     }
}



Subroutine£º

A set of instructions that performs a specific task for a main routine, requiring direction back to the proper place in the main routine on completion of the task.
Ò»×éΪÖ÷³ÌÐòÍê³ÉijÏîÌØ¶¨ÈÎÎñµÄÖ¸ÁºÏ£¬ÈÎÎñÒ»µ©Íê³ÉÐèÒªÌø×ª»ØÖ÷³ÌÐòºÏÊʵĵط½¡£


bletcherous£º

Disgusting in design or function; esthetically unappealing. This word is seldom used of people. ¡°This keyboard is bletcherous!¡± (Perhaps the keys don't work very well, or are misplaced.)
ÔÚÉè¼Æ»òÕßÊǹ¦ÄÜÉϵIJ»Âú£»ÌôÌÞʽµÄ±§Ô¹¡£Õâ¸ö´ÊÈËÃÇͨ³£¶¼²»ÔõôʹÓá£Èç
¡°Õâ¸ö¼üÅÌÓеãbletcherous£¡¡±

´Ë×ÊÁÏÀ´Ô´ÓÚÍøÉÏ¡£Ï£Íû¶Ô´ó¼ÒÓаïÖú

[ Last edited by sdlj8051 on 2006-10-6 at 11:22 ]
»Ø¸´´ËÂ¥

» ²ÂÄãϲ»¶

ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
Ïà¹Ø°æ¿éÌø×ª ÎÒÒª¶©ÔÄÂ¥Ö÷ sdlj8051 µÄÖ÷Ìâ¸üÐÂ
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] 335Çóµ÷¼Á +4 yuyuÓî 2026-03-23 5/250 2026-03-23 23:49 by Txy@872106
[¿¼ÑÐ] Çóµ÷¼Á +7 Ê®Èý¼ÓÓÍ 2026-03-21 7/350 2026-03-23 23:48 by ÈÈÇéɳĮ
[¿¼ÑÐ] 306Çó0703µ÷¼ÁÒ»Ö¾Ô¸»ªÖÐʦ·¶ +7 Ö½Óãly 2026-03-21 8/400 2026-03-23 23:31 by chixmc
[¿¼ÑÐ] 279·ÖÇóµ÷¼Á Ò»Ö¾Ô¸211 +17 chaojifeixia 2026-03-19 19/950 2026-03-23 23:26 by ´ô´ôʦ½ã
[¿¼ÑÐ] 335·Ö | ²ÄÁÏÓ뻯¹¤×¨Ë¶ | GPA 4.07 | ÓпÆÑо­Àú +4 cccchenso 2026-03-23 4/200 2026-03-23 23:00 by Ðìckkk
[¿¼ÑÐ] ÉúÎïѧһ־Ը985£¬·ÖÊý349Çóµ÷¼Á +6 zxts12 2026-03-21 9/450 2026-03-23 18:37 by macy2011
[¿¼ÑÐ] ¹¤¿Æ²ÄÁÏ085601 279Çóµ÷¼Á +8 À§ÓÚÐdz¿ 2026-03-17 10/500 2026-03-23 13:05 by ×íÔÚ·çÀï
[¿¼ÑÐ] 333Çóµ÷¼Á +6 87639 2026-03-21 10/500 2026-03-23 10:41 by Iveryant
[¿¼ÑÐ] 352Çóµ÷¼Á +3 ´óÃ×·¹£¡ 2026-03-22 3/150 2026-03-22 23:28 by king123£¡
[¿¼ÑÐ] ÉúÎïѧ071000 329·ÖÇóµ÷¼Á +5 ÎÒ°®ÉúÎïÉúÎﰮΠ2026-03-17 5/250 2026-03-22 16:42 by tcx007
[¿¼ÑÐ] 303Çóµ÷¼Á +5 °²ÒäÁé 2026-03-22 6/300 2026-03-22 12:46 by ËØÑÕÇã³Ç1988
[¿¼ÑÐ] 354Çóµ÷¼Á +7 Tyoumou 2026-03-18 10/500 2026-03-22 11:11 by ÈËÀ´Ê¢
[¿¼ÑÐ] 286·ÖÈ˹¤ÖÇÄÜרҵÇëÇóµ÷¼ÁÔ¸Òâ¿ç¿¼£¡ +4 lemonzzn 2026-03-17 8/400 2026-03-21 22:49 by lemonzzn
[¿¼ÑÐ] ¹ãÎ÷´óѧ²ÄÁϵ¼Ê¦ÍƼö +3 ÏÄÏÄÏÄСÕý 2026-03-17 5/250 2026-03-21 22:20 by ½ðê»ML
[¿¼ÑÐ] ²ÄÁϹ¤³Ìר˶ 348·ÖÇóµ÷¼Á +3 ¶¬´Ç. 2026-03-17 5/250 2026-03-21 18:47 by ѧԱ8dgXkO
[¿¼ÑÐ] ²ÄÁÏÓ뻯¹¤£¨0856£©304Çó BÇø µ÷¼Á +3 Çñgl 2026-03-21 3/150 2026-03-21 13:47 by lature00
[¿¼ÑÐ] 085700×ÊÔ´Óë»·¾³308Çóµ÷¼Á +12 īīĮ 2026-03-18 13/650 2026-03-21 01:42 by JourneyLucky
[¿¼ÑÐ] 295¸´ÊÔµ÷¼Á +8 ¼òľChuFront 2026-03-19 8/400 2026-03-20 20:44 by zhukairuo
[¿¼²©] É격26Äê +3 °Ë6°Ë68 2026-03-19 3/150 2026-03-19 19:43 by nxgogo
[˶²©¼ÒÔ°] ºþ±±¹¤Òµ´óѧ ÉúÃü¿ÆÑ§Ó뽡¿µÑ§Ôº-¿ÎÌâ×éÕÐÊÕ2026¼¶Ê³Æ·/ÉúÎï·½Ïò˶ʿ +3 1ϲ´º8 2026-03-17 5/250 2026-03-17 17:18 by ber´¨cool×Ó
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û