| ²é¿´: 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 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 ] |
» ²ÂÄãϲ»¶
276Çóµ÷¼Á¡£ÓаëÄêµç³ØºÍ°ëÄê¸ß·Ö×Óʵϰ¾Àú
ÒѾÓÐ10È˻ظ´
Ò»Ö¾Ô¸ÄϺ½²ÄÁÏר317·ÖÇóµ÷¼Á
ÒѾÓÐ4È˻ظ´
Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
ÉúÎïѧѧ˶Çóµ÷¼Á
ÒѾÓÐ5È˻ظ´
284Çóµ÷¼Á
ÒѾÓÐ10È˻ظ´
һ־Ըɽ¶«´óѧҩѧѧ˶Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
07»¯Ñ§280·ÖÇóµ÷¼Á
ÒѾÓÐ4È˻ظ´
298-Ò»Ö¾Ô¸Öйúũҵ´óѧ-Çóµ÷¼Á
ÒѾÓÐ12È˻ظ´
Çó²ÄÁÏ£¬»·¾³×¨Òµµ÷¼Á
ÒѾÓÐ3È˻ظ´
335Çóµ÷¼Á
ÒѾÓÐ5È˻ظ´













»Ø¸´´ËÂ¥