United States Patent 19 11 Patent Number: 5,628,017 Kimmerly Et Al
Total Page:16
File Type:pdf, Size:1020Kb
USO05628O17A United States Patent 19 11 Patent Number: 5,628,017 Kimmerly et al. 45 Date of Patent: May 6, 1997 54 METHOD AND SYSTEM FOR PROVIDING "Windows System Timers; Icon Questions; Rotating a Bit EVENTRESPONSE CAPABILITESTO map; Handling a Joystick” by Paul Bonneau Windows-DOS PSEUDOCODE Developer's Journal Oct. 1992 v3 n1.0. p. 27(12). "Dusting Off Applications” by Ronald Albury, UNIX 75 Inventors: Randy S. Kimmerly; Robert E. Saile, Review Jan. 1991 v9 n1 p. 40(5). both of Redmond, Wash. “Within Technologies Inc: Realizer 1.0", Julian Milenbach PC Week Sep. 16, 1991 v8 n37 p. 103(3). 73) Assignee: Microsoft Corporation, Redmond, "Microsoft Unveils Code-Crunching C 7.0 Compiler” by Wash. Karen D. Moser, PC Week Sep. 2, 1991 v8 n35 p. 1(2). 21 Appl. No.: 593,544 (List continued on next page.) Primary Examiner-Alvin E. Oberley 22 Fied: Jan. 29, 1996 Assistant Examiner Michael T. Richey Related U.S. Application Data Attorney, Agent, or Firm-Seed and Berry LLP 57 ABSTRACT I63) Continuation of Ser. No. 31,566, Mar. 15, 1993, abandoned. A method and system for providing event-response and 51 Int, Cl- imm. G06F 9/40 monitoring capabilities to a pseudocode program operating (52) U.S. Cl. ......................... 395/704; 395/707; 395/682; in a message or event-based operating environment. The 395/685; 364/280.8; 364/280.9 method and system allow the pseudocode program to asyn 58) Field of Search ................................... 395/700, 650, chronously respond to events via one or more trap routines 395/682, 685, 704, 707; 364/280.8, 280.9 located in the pseudocode program. The method and system also allow the pseudocode program to synchronously moni 56) References Cited tor events and receive parameters from operating system routines via callback routines located in the pseudocode U.S. PATENT DOCUMENTS program. The system includes an execution engine for 4.866,638 9/1989 Cosentino et al....................... 364/521 executing instructions of the pseudocode program. An 4,974,159 11/1990 Hargrove et al..... ... 364/200 event-response routine in the pseudocode program includes 5,148,544 9/1992 Cutler et al. ..... ... 395/725 instructions for responding to the event. An event-response 5,218,712 6/1993 Cutler et al. ..... ... 395/800 dispatcher is adapted to receive information identifying the 5,237,684 8/1993 Record et al. .......................... 395/650 event-response routine, save the execution state of the OTHER PUBLICATIONS execution engine, cause the execution engine to execute the event-response routine, and restore the execution state of the Microsoft C/C++ Programming Techniques, 3:43–53 execution engine that existed before the event-response (1991). routine was executed. A transfer routine accessible in Microsoft Windows Software Development Kit, Program response to a call triggered by the event accesses the mer's Reference, vol. 2: Functions:535-539, 625-626, event-response dispatcher, passes information identifying 894-899,956-958 (1992). the event-response routine to the event-response dispatcher, Petzold, Charles, "Programming Windows 3.1. Third Edi and returns control to the execution engine after the event tion.” The Microsoft Guide to Writing Applications for response dispatcher restores the state of the execution engine Windows 3.1:175-193, 907-929 (1992). and returns to the transfer routine. Microsoft Visual Basic Programming System for Windows: Professional Features:7-14, 57-63 (1992). 21 Claims, 7 Drawing Sheets Lldetector Routix Octics Eye Call trap dispatcher likalifier U 5,628,017 Page 2 OTHER PUBLICATIONS "Strategies for Optimizing Assembly Language Programs” “FoxPro 2.0: What's in it for you?” Alan Y. Griver et al. by Ray Duncan, PC Magazine Nov. 26, 1991 v10 n20 p. Data Based Advisor Jun. 1991 v9 nó p. 96(3). 511(4). "McDonnell Douglas Presses Software Vendors to Continue with Tuxedo Development”. Computergram International "Microsoft Brings Back P-Code; Technique Holds Promise Jun. 27, 1991 n1706. for Future Operating Systems” by Larry J. Seltzer PC Week “A Preview of MicroSoft cfc. 7 and the Microsoft Foun May 11, 1992 v9 n19 p.61(2). dation Classes for Windows" by Richard Hale Shaw, Microsoft Systems Journal Mar.-Apr. 1992 v7 n2 p. 43(13). “A Portable Menu Compiler: Part 5: CMENU” by Leon "Realizer Opens Windows” by Bruce Schatyman. DBMS Zolman, C Users Journal Aug. 1992 v10 n8 p116(11). Nov. 1991 v4 n12 p. 42(2). "Hook Up with Relational Databases"; Here's Why You “Are your Ready for Cutting Edge COBOL?” by Neel Snell Should Link Your Procedural-Language Product to a Datamation Oct. 15, 1992 v38 n21 p77(7). RDBMS, Data Based Advisor Feb. 1992 v10 n2 p. 74(9). "GUI Development Tools Take Giant Leap to Fourth Gen “The Xview Notifier” by Dan Heller, UnixWorld Jul. 1990, eration” by Steve Gibson, InfoWorld Sep. 2, 1991 v13 n35 pp. 123-133. p. 35(1). "Threaded Pseudo Code Gives Microsoft Visual Basic Its Shaw, R., “A Preview of Microsoft C/C++ 7 and the Edge" by Steve Gibson, InfoWorld Jul. 1, 1991 v13 n26 p. Microsoft Foundation Classes for Windows'. Microsoft 30(1). Systems Journal, Mar, 1992, pp. 43–55. U.S. Patent May 6, 1997 Sheet 1 of 7 5,628,017 10 CPU / Registers Figure 1 U.S. Patent May 6, 1997 Sheet 3 of 7 5,628,017 46 Compile Main Program Into Pseudocode 48 Call DLL Detector Routine 50 Pass Trap Dispatcher Pointer 52 Pass Trap Routine Identifie 54 Pass Activate Flag 56 Figure 3 Return To Main Program More Trap Routines? 60 Execute Pseudocode Program U.S. Patent May 6, 1997 Sheet 4 of 7 5,628,017 DLL Detector 62 Routine Detects Event 64 Call Trap Dispatcher 66 Pass Trap Routine Identifier 68 Store Execution Engine State Find 70 Associated Trap Routine 72 Execute Trap Routine Figure 4 Restore Execution Engine State 76 Return To DLL Detector Routine 78 Return To Program U.S. Patent May 6, 1997 Sheet 5 of 7 5,628,017 06 |zaupnosi 88 uue130J? 98 UueI3OJA U.S. Patent May 6, 1997 Sheet 6 of 7 5,628,017 98 Call Operating System (OS) Routine Pass OS Routine 00 Parameters & Thunk Address To OS Routine 02 Execute OS Routine 04 Return To Callback Thunk Figure 6A Pass Callback 106 Routine Parameters 08 Pass Callback Routine Index 10 Pass Execution Engine Data Segment Address U.S. Patent May 6, 1997 Sheet 7 of 7 5,628,017 Call Callback Dispatcher Save Execution Engine State Execute Callback Routine Restore Main Execution Engine State Return To Callback Thunk Return. To OS Routine Return To Main Program Execution 5,628,017 1. 2 METHOD AND SYSTEM FOR PROVIDING Like most programs, the execution engine interacts with EVENTRESPONSE CAPABILITESTO a computer operating system to access hardware devices of PSEUDOCODE the computer. Most advanced operating systems, such as the Microsoft Windows operating system and OS/2, are event CROSS-REFERENCE TO RELATED or message-based multitasking systems. In such event-based APPLICATION systems, the user interacts with windows, menus, and con trols in a user interface of a program. User-generated events, This application is a continuation of U.S. patent applica such as mouse clicks and keystrokes, place “messages' in tion Ser. No. 08/031,566, filed Mar. 15, 1993, now aban the program's message queue. The program uses a message doned. loop to get messages from the queue and send the messages 10 to the appropriate window for handling by a window pro TECHNICAL FIELD cedure. Each window is associated with a window procedure The present invention relates generally to computer pro that responds to the messages received from the message gram interfacing, and more particularly to interfacing loop. Alternatively, messages can be sent directly from an pseudocode programs with an event-based operating envi operating system routine to the window procedure without 15 using the message queue if the operating system routine is rOnment. given a pointer to the window procedure. BACKGROUND OF THE INVENTION The window procedure is a type of routine known as a callback routine. In general, a callback routine is a routine A computer program is usually written in a language other that receives messages or other information from another than the machine language used by the computer to execute routine, such as an operating system routine. The informa the program. The reason is that machine language is not tion received can be asynchronous relative to the execution designed for human communication. Because computers of the callback routine, that is, the information is received at utilize two-state storage and switching devices, sequences of unexpected times. System interrupts and messages received binary digits provide the most natural form for expressing based on user input, i.e. window messages, are examples of program instructions. However, sequences of binary digits 25 asynchronous information. The information received also are very unnatural for humans to construct or to understand. can be synchronous, that is, information received according The language in which a computer program is written is to a synchronous execution of instructions. Synchronous called source code. A translator is used to translate the information results when a program calls a routine, such as source code into machine language understandable by the an operating system routine and tells the operating system computer. In some systems, a first translator translates the 30 routine to "call back” to a callback routine in the program. Source code into an intermediate language, such as an The call back to the callback routine passes information assembly language, and a second translator translates the produced by execution of the operating system routine.