Lecture 6 : Multitasking & DLL
|
|
- Alban King
- 5 years ago
- Views:
Transcription
1 Lecture 6 : Multitasking & DLL Multitask CreadThread, ExitThread, TerminateThread beginthreadex, endthreadex : memory leak SuspendThread, ResumeThread Sleep Thread priorities Synchronization CreateSemaphore, WaitForSingleObject, ReleaseSemaphore DLL Static library work vs Dynamic library work Load-time, Run-time How to create DLL How to use DLL 1
2 Part I :Multitasking Windows application can consist of more than one process (a program) A process can consist of more than one thread Win 32 API support multitasking Create the effect of simultaneous execution of multiple processes and threads Focus on multi-thread a process consist of more than one thread 2
3 Threads Concept Multiple threads on multiple CPUs Multiple threads sharing a single CPU Thread 1 Thread 2 Thread 3 Thread 1 Thread 2 Thread 3 3
4 thread1 thread 2 Multitasking (cont.) A multitasking operating system divides the available CPU time among the threads that need it. In windows, the Win 32 API is designed for preemptive multitasking Means the system allocates small slices of CPU time among the competing threads Currently executing thread is suspended when its time slice elapses (20 ms.) single processor system Advantage of multitasking To the user Ability to have several applications open and working at the same time. Ex: A user can edit a file with one app while another app is printing a spreadsheet To the application developer Ability to create app that to create a process that use more than one thread of execution ex. One thread for handling interactions with the user while other threads with low priority perform the other work of the process 4
5 Creating a Thread To create a thread, use th API function CreateThread() HANDLE CreateThread( LPSECURITY_ATTRIBUTES lpthreadattributes, // pointer to security attributes DWORD dwstacksize, // initial thread stack size LPTHREAD_START_ROUTINE lpstartaddress, // pointer to thread function LPVOID lpparameter, // Pointer to a variable to be passed to the thread DWORD dwcreationflags, // creation flags LPDWORD lpthreadid // pointer to receive thread ID ); A thread of execution terminates when its entry function returns DWORD WINAPI ThreadProc( LPVOID lpparameter); ThreadProc เป นช ออะไรก ได 5
6 Creating a Thread Parameters 1: NULL to get the default security descriptor 2: the size of the new thread s stack, in bytes, common approach 0 3: thread function: DWORD WINAPI ThreadProc( LPVOID lpparameter); 4: any argument that needs to pass to the new thread (lpparameter) 5: the execution state of the thread 0 : begin execution immediately CREATE_SUSPENDED : awaiting execution, Call to ResumeThread() function 6: identifier associated with a thread Thread ID If successful the function returns a handle to the thread If failure returns NULL Hthread1 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MyThread1, (LPVOID) hwnd, 0, &Tid1) ; DWORD WINAPI MyThread1(LPVOID param) {..} 6
7 Thread s Life cycle Blocked ResumeThread() new Ready scheduler Running t1=createthread( p1,p2,p3,p4,0,p6) Fn.thread return t1=createthread( p1,p2,p3,p4, CREATE_SUSPENDED,p6) Finished 7
8 DWORD Tid; LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { HANDLE hthread; int response; } switch(message) { case WM_COMMAND: switch(loword(wparam)) { case IDM_THREAD: /* เมส ไว ส าหร บสร าง Thread create the threads */ hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MyThread1, break; Demo Program :ThreadEx1 threadex1 (LPVOID)hwnd, 0, &Tid1); DWORD WINAPI MyThread1(LPVOID param) { } int i; HDC hdc; for(i=0; i<max; i++) { } sprintf(str, "Thread 1: loop # %5d ", i); hdc = GetDC((HWND) param);// ใช พาราม เตอร ท ส งมา TextOut(hdc, 1, 1, str, strlen(str)); ReleaseDC((HWND) param, hdc); return 0; 8
9 Terminating a Thread Terminate the thread manually BOOL TerminateThread(HANDLE hthread,dword dwexitcode); May stop a thread during an important operation Does not perform any special cleanup activities For example, TerminateThread can result in the following problems: If the target thread owns a critical section, the critical section will not be released. If the target thread is allocating memory from the heap, the heap lock will not be released. Return values Nonzero success Zero fail VOID ExitThread(DWORD dwexitcode); Stack is properly reset : return normally 9
10 Alternatives to CreateThread() and ExitThread() If a multithreaded program utilizes standard C library functions (sprintf, strlen, etc.) Use of the CreateThread() and ExitThread() causes small memory leaks ม ว ธ แก 2 ว ธ ค อ ใช CreateThread() & ExitThread() ของ win 32 ก บ functionท ท างานเหม อน standard C library fn. ของ win 32 ใช C runtime library to start และ stop thread แทนการ ใช CreateThread() & ExitThread() 10
11 ว ธ ท หน ง: Avoiding the C Library Functions Still use a function CreateThread(), ExitThread() Win 32 contains substitutes for several C string handling functions wsprintf(), lstrlen(), lstrcat(), lstrcpy(), CharUpper(), CharLower(), IsCharAlpha(), IsCharAlphaNumeric(), etc. 11
12 ว ธ ท สอง:Using C runtime library using C runtime library to start and stop thread _beginthreadex() and endthreadex() #include <process.h> setting a project property to be multi-threaded debug _beginthreadex(null, 0, MyThread1,(LPVOID) hwnd, 0,(unsigned *) &Tid1); #include <process.h>... unsigned _stdcall MyThread1(void * param) { TextOut(hdc, 250, 180, str, strlen(str)); ReleaseDC((HWND) param, hdc); } return 0; } Demo Program: ThreadEx2 เป ดโปรเจ ค 12
13 Project [ThreadEx2]Properties.. Visual 2005 จะเป น default ให แต Visual 2003 ต องมาเซ ตเอง 13
14 Suspending and Resuming a Thread DWORD SuspendThread(HANDLE hthread); DWORD ResumeThread(HANDLE hthread); hthread is a returned value of function CreateThread() VOID Sleep(DWORD Duration // length of time, in milliseconds); ไว ในฟ งก ช นของ Thread hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MyThread1, (LPVOID)hwnd, 0, &Tid1); 5 th Parameter :CREATE_SUSPENDED 14
15 Thread s Life cycle Time out ResumeThread() Blocked Sleep() SuspendThread() new Ready Running scheduler t1=createthread( p1,p2,p3,p4,0,p6) Fn.thread return Finished 15
16 Thread Priorities A thread s priority determines how much CPU time a thread receives Low-priority threads receive little High-priority threads receive a lot A thread s priority setting is the combination of two values: The overall priority class of the process and The priority setting of the individual thread relative to that priority class BOOL SetThreadPriority( HANDLE hthread, // handle to the thread int npriority // thread priority level ); int GetThreadPriority( HANDLE hthread // handle to thread ); 16
17 SetThreadPriority(HANDLE hthread, int npriority ) Priority Meaning THREAD_PRIORITY_ABOVE_NORMAL Priority 1 point above the priority class THREAD_PRIORITY_BELOW_NORMAL Priority 1 point below the priority class THREAD_PRIORITY_HIGHEST Priority 2 points above the priority class THREAD_PRIORITY_LOWEST Priority 2 points below the priority class. THREAD_PRIORITY_NORMAL Normal priority for the priority class. link DWORD GetPriorityClass( HANDLE hprocess ); ร บค า priority ของ process 17
18 Synchronization When using multiple threads, it is sometimes necessary to coordinate the activities of two or more. This process is called synchronization The most common reason for this is when two or more threads need access to a shared resource One thread is writing a file A second thread must be prevented from doing so at the same time There are two general states that a task may be in: Executing ( or ready to execute as soon as it obtain its time slice) Blocked, awaiting some resource, in which case its execution is suspended until the needed resource is available 18
19 Semaphore File File is is not in in use. use. Thread Write a file File Thread Read a file 19
20 Using a Semaphore to Synchronize Threads HANDLE CreateSemaphore( LPSECURITY_ATTRIBUTES lpsemaphoreattributes, // pointer to //security attributes, NULL LONG linitialcount, //ม ท ว างส าหร บเทรดก ท 0 linitialcount lmaximumcount LONG lmaximumcount, // maximum count,ร นพร อมๆ ก นได ก เทรด lmaximumcount 0 LPCTSTR lpname // pointer to semaphore-object name ); DWORD WaitForSingleObject( HANDLE hhandle, // handle to semaphore object to wait for DWORD dwmilliseconds // time-out interval in milliseconds ); BOOL ReleaseSemaphore( HANDLE hsemaphore, // handle to the semaphore object LONG lreleasecount, // amount to add to current count LPLONG lppreviouscount // address of previous count,null ); ย งคงใช ค าส ง CreateThread() เหม อนเด ม Demo: Semaphore 20
21 Using a Semaphore to Control Resource :MyThread1, MyThread2 Count = 1 Initialize Semaphore Resource status Thread1 be in use Count = 0 Thread2 wait on Semaphore Handle Thread2 release Semaphore Thread2 be in use Count = 0 Thread1 release Semaphore Count = 1 Resource status Available for Thread2 21
22 HANDLE hsema; LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) {... case WM_CREATE: hsema = CreateSemaphore(NULL, 1, 1, NULL);// case WM_COMMAND: wmid = LOWORD(wParam); // Parse the menu selections: switch (wmid) { case IDM_THREAD: break; CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MyThread1, (LPVOID)hWnd, 0, &Tid1); CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MyThread2, (LPVOID)hWnd, 0, &Tid2); } break; Create a Semaphore 22
23 DWORD WINAPI MyThread1(LPVOID param) { int i; HDC hdc; // wait for access to be granted if (WaitForSingleObject(hSema, INTERVAL) == WAIT_TIMEOUT) { MessageBox((HWND)param, "Time out Thread 1", "Semaphore Error", MB_OK); return 0; } for (i = 0; i < MAX; i++) { if (i == MAX/2) { // Release at half way point. This allows MyThread2 to run ReleaseSemaphore(hSema, 1, NULL);... } 23
24 DWORD WINAPI MyThread2(LPVOID param) { char str[255]; int i; HDC hdc; // wait for access to be granted if (WaitForSingleObject(hSema, INTERVAL) == WAIT_TIMEOUT){ MessageBox((HWND)param, "Time out Thread 2 ", "Semaphore Error", MB_OK); return 0; } for (i = 0; i < MAX; i++){ wsprintf(str, "Thread 2 : loop # %5d ", i); hdc = GetDC((HWND)param); TextOut(hdc, 1, 20, str, lstrlen(str)); ReleaseDC((HWND)param, hdc); } ReleaseSemaphore(hSema, 1, NULL); return 0; }/ Semaphore1_1.exe ด ไฟล semaphore.pdf 24
25 C:\Program Files\Microsoft Visual Studio 8 \Common7\Tools\Bin\winnt\pview.exe link 25
26 Part II : Creating DLLs How does Static Library work? Static Library Copy added to each program during linking Library function ProgramA.exe ProgramB.exe ProgramC.exe Library function Library function Library function 26
27 How DLLsWork: Load-time Dynamic Linking 4.ProgramB loaded 1.ProgramA loaded Library.dll ProgramC.exe ProgramB.exe ProgramA.exe 2.DLL loaded 6.ProgramC loaded ProgramA ProgramB ProgramC Library.dll 5. Linkage to DLL function Library function 3.Linkage to DLL function 7. Linkage to DLL function Computer Memory 27
28 How DLLsWork: Run-time Dynamic Linking Library1.dll Library2.dll 3.Library2.dll loaded at the request of the program. 1.ProgramA loaded but no DLL is loaded. The program may use any one of three DLLs. Library3.dll Program.exe Program 2. At this point the program Determines that Library2.dll is required and causes it to be loaded. 4. The program obtains the address of a function from the DLL and uses it to call the function Library2.dll Library function Computer Memory 28
29 Creating DLLs Why? Placing functions in a DLL reduces the size of each component because the functions are not duplicated in each program Using DLLs makes upgrades easier Only the DLL file must be recompiled DLL Basics Any function contained in a DLL that will be called by code outside the DLL must be exported (use dllexport keyword) To use a function contained in a DLL, u must import (use dllimport keyword) it 29
30 Creating a DLL The dllexport and dllimport keywords cannot be used by themselves They need to be preceded by keyword: _declspec(specifier) Ex: Creating a DLL _declspec(dllexport) void MyFunc(int a) { } สร างเป น macro name #define DllExport _declspec (dllexport)... DllExport void MyFuncOne(int a){ } DllExport void MyFuncTwo(){ } If yr Dll is compiled as a C++ program, u want it to also be usable by C program #define DllExport extern C _declspec (dllexport) ต องใช C พ มพ ใหญ 30
31 Creating a DLL 31
32 Select DLL & Empty project 32
33 Project Add NewItem.. 33
34 Creating a Simple DLL Mydll.cpp #include <windows.h> #include <cstring> #define DllExport extern "C" _declspec (dllexport) /* This function displays the coordinates of the mouse at the point at which a mouse button was pressed. hdc: Specifies the device context in which to output the coordinates. lparam: Specifies the value of lparam when the button was pressed. */ DllExport void ShowMouseLoc(HDC hdc, LPARAM lparam) { char str[80]; wsprintf(str, "Button is down at %d, %d", LOWORD(lParam), HIWORD(lParam)); TextOut(hdc, LOWORD(lParam), HIWORD(lParam),str, strlen(str)); } Create a c++ file(*.cpp) that contains some functions to be a DLL. 34
35 Next Step Build DLL, can not run! If success u will get a *.dll & *.lib files in the directory Debug.dll file will contain the code for the functions that will be dynamically linked.lib file contains loading information that must be linked with any application that uses the library (during compile need this file) Open project :MyDll 35
36 Using the DLL :Load-time Dynamic Linking #include <windows.h> #include <cstring> #include testmydll.h // import dll s function LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM); char szwinname[] = "MyWin"; // name of window class testmydll.cpp int WINAPI WinMain(HINSTANCE hthisinst, HINSTANCE hprevinst, LPSTR lpszargs, int nwinmode) { } LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { HDC hdc; switch(message) { case WM_RBUTTONDOWN: // process right button hdc = GetDC(hwnd); // get DC ShowMouseLoc(hdc, lparam); // call DLL function ReleaseDC(hwnd, hdc); // Release DC break; case WM_LBUTTONDOWN: // process left button hdc = GetDC(hwnd); // get DC ShowMouseLoc(hdc, lparam); // call DLL function ReleaseDC(hwnd, hdc); // Release DC break; case WM_DESTROY: // terminate the program PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wparam, lparam); } return 0; } 36
37 --Header file --Implement a DLL testmydll.h file #define DllImport extern "C" _declspec (dllimport) DllImport void ShowMouseLoc(HDC hdc, LPARAM lparm); เป นการบ งบอกว าจะ import function อะไรจาก dll เข ามาใน application การจ ดสภาพแวดล อมของ app ท เร ยกใช dll During development an application using a dll Two files ; *.dll, *.lib ; contains in the directory of the application Project AddExisting item ส าหร บไฟล.lib After that we need only.dll file to carry with *.exe file Demo Project: TestMyDll 37
38 Run-time Dynamic Linking Most often, when you use functions defined in a DLL, yr program calls those functions by name in its source code. Ex.. ShowMouseLoc() For this case, the Dll that contains the function is loaded when the application is loaded called loadtime dynamic linking (เป นว ธ ในสไลด ท กล าวมาแล ว) It is possible to load dynamic link libraries at runtime called run-time dynamic linking Yr program must manually load the Dll and then obtain pointers to the function that it wishes to use 38
39 Run-time Dynamic Linking At the core of run-time dynamic linking are these three functions: HMODULE LoadLibrary(LPCTSTR lpfilename); Loads the DLL specified by lpfilename and returns a handle to it FARPROC GetProcAddress( HMODULE hmodule, LPCSTR lpprocname ); Returns a pointer to the function named by lpprocname that is contained in the DLL specified by hmodule lpprocname must match exactly the name specified within the DLL BOOL FreeLibrary( HMODULE hmodule ); Frees the DLL when it is no longer needed hlib = LoadLibrary("MYDLL.DLL"); void (*f)(hdc, LPARAM); // get pointer to ShowMouseLoc f = (void (*)(HDC, LPARAM)) GetProcAddress(hlib, "ShowMouseLoc"); // call ShowMouseLoc (*f)(hdc, lparam); FreeLibrary(hlib); Demo Program : UsingLoadLibrary 39
40 C:\Program Files\Microsoft Visual Studio 8 \Common7\Tools\Bin\Depends.Exe link 40
Multi-core Architecture and Programming
Multi-core Architecture and Programming Yang Quansheng( 杨全胜 ) http://www.njyangqs.com School of Computer Science & Engineering 1 http://www.njyangqs.com Programming with Windows Threads Content Windows
More informationThreads in Java. Threads (part 2) 1/18
in Java are part of the Java language. There are two ways to create a new thread of execution. Declare a class to be a subclass of Thread. This subclass should override the run method of class Thread.
More informationCS 453/552: Operating Systems Midterm Examination
CS 453/552: Operating Systems Midterm Examination Time: 110 minutes Name : Total Points: 150 This exam has 9 questions, for a total of 165 points. Graduate students need to answer all questions. There
More informationCreating Threads. Programming Details. COMP750 Distributed Systems
Creating Threads Programming Details COMP750 Distributed Systems Thread and Process Creation Processes can be created on Unix systems in C or C++ using the fork() function. Threads can be created in C
More informationSocket I/Os in Windows. Dae-Ki Kang
Socket I/Os in Windows Dae-Ki Kang Agenda TCP Server/Client Multi-Threads Synchronization Socket IO Model WSAAsyncSelect Model WSAEventSelect Model UDP Server/Client Overlapped Model Completion Port Model
More informationProgramming in graphical environment. Introduction
Programming in graphical environment Introduction The lecture Additional resources available at: http://www.mini.pw.edu.pl/~maczewsk/windows_2004 Recommended books: Programming Windows - Charles Petzold
More informationAdvantech Windows CE.net Application Hand on Lab
Advantech Windows CE.net Application Hand on Lab Lab : Serial Port Communication Objectives After completing this lab, you will be able to: Create an application to open, initialize the serial port, and
More informationProcesses. 4: Threads. Problem needs > 1 independent sequential process? Example: Web Server. Last Modified: 9/17/2002 2:27:59 PM
Processes 4: Threads Last Modified: 9/17/2002 2:27:59 PM Recall: A process includes Address space (Code, Data, Heap, Stack) Register values (including the PC) Resources allocated to the process Memory,
More informationWindows to Linux Porting Library
Library Windows to Linux Porting Library ( W2LPL ) ADONTEC, 2012. All Rights Reserved. www.adontec.com This document describes how to use the W2LPL library within a custom application. Technical Support
More informationCreating Threads COMP755
Creating Threads COMP755 "I pledged California to a Northern Republic and to a flag that should have no treacherous threads of cotton in its warp, and the audience came down in thunder." Thomas Starr King
More informationISI Web of Science. SciFinder Scholar. PubMed ส บค นจากฐานข อม ล
2.3.3 Search Chem. Info. in Journal ส บค นจากฐานข อม ล - ฐานข อม ลท รวบรวมข อม ลของ journal จากหลาย ๆ แหล ง ISI http://portal.isiknowledge.com/portal.cgi/ SciFinder ต องต ดต งโปรแกรมพ เศษ และสม ครสมาช
More informationChapter 8: Memory- Management Strategies Dr. Varin Chouvatut
Part I: Overview Part II: Process Management Part III : Storage Management Chapter 8: Memory- Management Strategies Dr. Varin Chouvatut, Silberschatz, Galvin and Gagne 2010 Chapter 8: Memory Management
More informationRAM fork join volatile variables critical sections memory barriers Critical section int global = 0; private void work( ) int local = 0; local++; global++; int Sum = 0; private void work( ) Sum++; mov
More informationว ธ การต ดต ง Symantec Endpoint Protection
ว ธ การต ดต ง Symantec Endpoint Protection 1. Download File ส าหร บการต ดต ง 2. Install Symantec Endpoint Protection Manager 3. Install License 4. Install Symantec Endpoint Protection Client to Server
More informationGet detailed information from
MS Windows API for Processes/Threads In MS Windows, the system call interface is not documented. Instead the MS Windows API is documented, which helps with being able to run programs portably across muliple
More informationWindows Programming. 1 st Week, 2011
Windows Programming 1 st Week, 2011 시작하기 Visual Studio 2008 새프로젝트 파일 새로만들기 프로젝트 Visual C++ 프로젝트 Win32 프로젝트 빈프로젝트 응용프로그램설정 Prac01 솔루션 새항목추가 C++ 파일 main.cpp main0.cpp cpp 다운로드 솔루션빌드 오류 Unicode vs. Multi-Byte
More informationWindow programming. Programming
Window programming 1 Objectives Understand the mechanism of window programming Understand the concept and usage of of callback functions Create a simple application 2 Overview Windows system Hello world!
More informationC Programming
204216 -- C Programming Chapter 9 Character Strings Adapted/Assembled for 204216 by Areerat Trongratsameethong A First Book of ANSI C, Fourth Edition Objectives String Fundamentals Library Functions Input
More informationWin32 Programming. Jim Fawcett CSE775 Distributed Objects Spring 2012
Win32 Programming Jim Fawcett CSE775 Distributed Objects Spring 2012 References Programming Applications for Microsoft Windows, 4 th Edition, Jeffrey Richter, Microsoft Press, 1999 Unicode, More Unicode
More informationCSCE Introduction to Computer Systems Spring 2019
CSCE 313-200 Introduction to Computer Systems Spring 2019 Threads Dmitri Loguinov Texas A&M University January 29, 2019 1 Updates Quiz on Thursday System Programming Tutorial (pay attention to exercises)
More informationComputer Programming Lecture 11 이윤진서울대학교
Computer Programming Lecture 11 이윤진서울대학교 2007.1.24. 24 Slide Credits 엄현상교수님 서울대학교컴퓨터공학부 Computer Programming, g, 2007 봄학기 Object-Oriented Programming (2) 순서 Java Q&A Java 개요 Object-Oriented Oriented Programming
More informationWindows Socket I/O Multiplexing. Prof. Lin Weiguo Copyleft 2009~2017 School of Computing, CUC
Windows Socket I/O Multiplexing Prof. Lin Weiguo Copyleft 2009~2017 School of Computing, CUC Dec 2016 Note You should not assume that an example in this presentation is complete. Items may have been selected
More informationLecture 5: Introducing Dialog Boxes & Child Window Controls for Win 32 API
Lecture 5: Introducing Dialog Boxes & Child Window Controls for Win 32 API What is Dialog Box? How to make your project to have a Dialog Box Modal Dialog Modeless Dialog WM_INITDIALOG Child Window Controls
More informationC Programming
204216 -- C Programming Chapter 5 Repetition Adapted/Assembled for 204216 by Areerat Trongratsameethong Objectives Basic Loop Structures The while Statement Computing Sums and Averages Using a while Loop
More informationWindows Printer Driver User Guide for NCR Retail Printers. B Issue G
Windows Printer Driver User Guide for NCR Retail Printers B005-0000-1609 Issue G The product described in this book is a licensed product of NCR Corporation. NCR is a registered trademark of NCR Corporation.
More informationLSN 4 GUI Programming Using The WIN32 API
LSN 4 GUI Programming Using The WIN32 API ECT362 Operating Systems Department of Engineering Technology LSN 4 Why program GUIs? This application will help introduce you to using the Win32 API Gain familiarity
More informationMultithreading Application in Win32
Copyright, 2000 Multimedia Lab., Multithreading Application in Win32 Chapter 3_Hurry Up and Wait Eung-Sang Kim Kim-0103@mmlab.net Multimedia Lab. Dept. of Electrical and Computer Eng. University of Seoul
More information4 th (Programmatic Branch ) Advance Windows Programming class
Save from: www.uotechnology.edu.iq 4 th (Programmatic Branch ) Advance Windows Programming class برمجة نوافذ المتقدمة أعداد :م.علي حسن حمادي 2006... 2010 >==> 2012 2013 CONTENTS: The Components of a Window
More informationWe display some text in the middle of a window, and see how the text remains there whenever the window is re-sized or moved.
1 Programming Windows Terry Marris January 2013 2 Hello Windows We display some text in the middle of a window, and see how the text remains there whenever the window is re-sized or moved. 2.1 Hello Windows
More informationGame Programming I. Introduction to Windows Programming. Sample Program hello.cpp. 5 th Week,
Game Programming I Introduction to Windows Programming 5 th Week, 2007 Sample Program hello.cpp Microsoft Visual Studio.Net File New Project Visual C++ Win32 Win32 Project Application Settings Empty project
More informationChapter 15 Programming Paradigm
Chapter 15 Programming Paradigm A Windows program, like any other interactive program, is for the most part inputdriven. However, the input of a Windows program is conveniently predigested by the operating
More informationPCI Software Manual [for Windows 95/98/NT/2000/XP]
PCI-1002 Software Manual [for Windows 95/98/NT/2000/XP] Warranty All products manufactured by ICP DAS are warranted against defective materials for a period of one year from the date of delivery to the
More informationDLL Software Manual. Copyright 2015 by ICP DAS. All rights are reserved.
Version 1.4, Jun. 2015 SUPPORTS Board includes PISO-C64(U), PEX-C64, PISO-P64, PISO-P64U(-24V), PEX-P64(-24V), PISO-730U, PISO-730(-5V), PEX-730, PISO-730A(-5V), PEX-P32A32, PISO-32A32(U)(-5V), PISO-P32C32(U)(-5V),
More informationProcessing in Frequency Domain
Will Pirkle FFT Processing (or Frequency Domain Processing) is a complete DSP topic on its own - thick books have been written about using the frequency domain representation of a signal for analysis or
More informationhinstance = ((LPCREATESTRUCT)lParam)->hInstance obtains the program's instance handle and stores it in the static variable, hinstance.
1 Programming Windows Terry Marris Jan 2013 6 Menus Three programs are presented in this chapter, each one building on the preceding program. In the first, the beginnings of a primitive text editor are
More informationIS311. Data Structures and Java Collections
IS311 Data Structures and Java Collections 1 Algorithms and Data Structures Algorithm Sequence of steps used to solve a problem Operates on collection of data Each element of collection -> data structure
More informationLes API WIN32. Auteur : J. ALVAREZ Catégorie : Cours Département : IRIST. Sujet : Langage ( V 2 ) Les API WIN32. Refs : CLngAPIWIN32
Auteur : J. ALVAREZ Catégorie : Cours Département : IRIST Sujet : Langage ( V 2 ) Refs : CLngAPIWIN32 SOMMAIRE 1 PROCESSES AND THREADS... 3 1.1 ABOUT PROCESSES AND THREADS... 3 1.2 MULTITASKING...3 1.3
More informationDeveloper Documentation
Developer Documentation Development of Scanner Applications for ACD Windows CE Second Edition Devices Version: 3.0 Copyright ACD Gruppe This document may not be duplicated or made accessible to third parties
More informationI/O. Output. Input. Input ของจาวา จะเป น stream จะอ าน stream ใช คลาส Scanner. standard input. standard output. standard err. command line file.
I/O and Exceptions I/O Input standard input keyboard (System.in) command line file Output standard output Screen (System.out) standard err file System.err Input ของจาวา จะเป น stream จะอ าน stream ใช คลาส
More informationWhat is a Process. Processes. Programs and Processes. System Classification 3/5/2013. Process: An execution stream and its associated state
What is a Process Process: An execution stream and its associated state Processes Execution Stream Set of instructions Thread of control Process State Hardware state Privilege level, segments, page tables
More informationCPE 426 Computer Networks. Chapter 5: Text Chapter 23: Support Protocols
CPE 426 Computer Networks Chapter 5: Text Chapter 23: Support Protocols 1 TOPICS สร ปเร อง IP Address Subnetting Chapter 23: Supporting Protocols ARP: 23.1-23.7 ใช ส าหร บหา HW Address(MAC Address) ICMP:
More informationการสร างเว บเซอร ว สโดยใช Microsoft.NET
การสร างเว บเซอร ว สโดยใช Microsoft.NET อ.ดร. กานดา ร ณนะพงศา ภาคว ชาว ศวกรรมคอมพ วเตอร คณะว ศวกรรมคอมพ วเตอร มหาว ทยาล ยขอนแก น บทน า.NET เป นเคร องม อท เราสามารถน ามาใช ในการสร างและเร ยกเว บเซอร ว สได
More informationI/O Multiplexing. Dec 2009
Windows Socket I/O Multiplexing http://icourse.cuc.edu.cn/networkprogramming/ linwei@cuc.edu.cn Dec 2009 Note You should not assume that an example in this presentation is complete. Items may have been
More informationเคร องว ดระยะด วยแสงเลเซอร แบบม อถ อ ย ห อ Leica DISTO ร น D110 (Bluetooth Smart) ประเทศสว ตเซอร แลนด
เคร องว ดระยะด วยแสงเลเซอร แบบม อถ อ ย ห อ Leica DISTO ร น D110 (Bluetooth Smart) ประเทศสว ตเซอร แลนด 1. ค ณล กษณะ 1.1 เป นเคร องว ดระยะทางด วยแสงเลเซอร แบบม อถ อ 1.2 ความถ กต องในการว ดระยะทางไม เก น
More informationINPUT Input point Measuring cycle Input type Disconnection detection Input filter
2 = TEMPERATURE CONTROLLER PAPERLESS RECORDER หน าจอเป น Touch Sceen 7-Inch LCD เก บข อม ลผ าน SD Card และ USB Memory ร บ Input เป น TC/RTD/DC Voltage/DC Current ร บ Input 6 Channel ช วงเวลาในการอ านส
More information/*********************************************************************
Appendix A Program Process.c This application will send X, Y, Z, and W end points to the Mx4 card using the C/C++ DLL, MX495.DLL. The functions mainly used are monitor_var, change_var, and var. The algorithm
More informationAbout INtime Win32 and real time extension system calls
About INtime Win32 and real time extension system calls Contents Overview How the Win32 API (iwin32) fits in the INtime environment INtime Win32 system calls Porting a Windows application to INtime Overview
More informationLecture Contents. 1. Overview. 2. Multithreading Models 3. Examples of Thread Libraries 4. Summary
Lecture 4 Threads 1 Lecture Contents 1. Overview 2. Multithreading Models 3. Examples of Thread Libraries 4. Summary 2 1. Overview Process is the unit of resource allocation and unit of protection. Thread
More informationChapter 4: Threads. Operating System Concepts with Java 8 th Edition
Chapter 4: Threads 14.1 Silberschatz, Galvin and Gagne 2009 Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples 14.2 Silberschatz, Galvin and Gagne
More informationChapter 3 Outline. Relational Model Concepts. The Relational Data Model and Relational Database Constraints Database System 1
Chapter 3 Outline 204321 - Database System 1 Chapter 3 The Relational Data Model and Relational Database Constraints The Relational Data Model and Relational Database Constraints Relational Model Constraints
More informationCall DLL from Limnor Applications
Call DLL from Limnor Applications There is a lot of computer software in the format of dynamic link libraries (DLL). DLLCaller performer allows your applications to call DLL functions directly. Here we
More informationLab 10: Structs and Enumeration
Lab 10: Structs and Enumeration There is one more way to create your own value types in C#. You can use the struct keyword. A struct (short for structure) can have its own fields, methods, and constructors
More informationWindows Programming in C++
Windows Programming in C++ You must use special libraries (aka APIs application programming interfaces) to make something other than a text-based program. The C++ choices are: The original Windows SDK
More informationChapter 9: Virtual-Memory Management Dr. Varin Chouvatut. Operating System Concepts 8 th Edition,
Chapter 9: Virtual-Memory Management Dr. Varin Chouvatut, Silberschatz, Galvin and Gagne 2010 Chapter 9: Virtual-Memory Management Background Demand Paging Copy-on-Write Page Replacement Allocation of
More informationCS410 Visual Programming Solved Online Quiz No. 01, 02, 03 and 04. For Final Term Exam Preparation by Virtualians Social Network
CS410 Visual Programming Solved Online Quiz No. 01, 02, 03 and 04 For Final Term Exam Preparation by Virtualians Social Network 1. Ptr -> age is equivalent to *ptr.age ptr.age (ptr).age (*ptr).age 2. is
More informationHANNAH HOWARD #ABOUTME
HANNAH HOWARD #ABOUTME Personal @techgirlwonder hannah@carbon Anecdote: I have ve.com a dog she/her REACTIVE PROGRAMMING: A Better Way to Write Frontend Applications 1. PROBLEM STATEMENT WHAT IS A COMPUTER
More informationx86.virtualizer source code
x86.virtualizer source code author: ReWolf date: IV/V.2007 rel.date: VIII.2007 e-mail: rewolf@rewolf.pl www: http://rewolf.pl Table of contents: 1. Usage 2. Compilation 3. Source code documentation - loader
More informationMultithreading Multi-Threaded Programming. Prof. Lin Weiguo Copyleft 2009~2017, School of Computing, CUC
Multithreading Multi-Threaded Programming Prof. Lin Weiguo Copyleft 2009~2017, School of Computing, CUC Oct. 2017 Note You should not assume that an example in this presentation is complete. Items may
More informationCreating a DirectX Project
Creating a DirectX Project A DirectPLay Chat Program Setting up your Compiler for DirectX Install DirectX SDK Make sure your compiler has path to directx8/include Directx8/lib Directx8/samples/multimedia/common/src
More informationChapter 3 Process Description and Control
Operating Systems: Internals and Design Principles Chapter 3 Process Description and Control Seventh Edition By William Stallings Example of Standard API Consider the ReadFile() function in the Win32 API
More informationC Windows 16. Visual C++ VC Borland C++ Compiler BCC 2. Windows. c:\develop
Windows Ver1.01 1 VC BCC DOS C C Windows 16 Windows98/Me/2000/XP MFC SDL Easy Link Library Visual C++ VC Borland C++ Compiler BCC 2 2 VC MFC VC VC BCC Windows DOS MS-DOS VC BCC VC BCC VC 2 BCC5.5.1 c:\develop
More informationMixed-Language Debugging of projects containing C and COBOL
Mixed-Language Debugging of projects containing C and COBOL Net Express and other Micro Focus software development tools offer a wide range of possibilities to construct COBOL projects. Of course, programs
More informationWindows and Messages. Creating the Window
Windows and Messages In the first two chapters, the sample programs used the MessageBox function to deliver text output to the user. The MessageBox function creates a "window." In Windows, the word "window"
More informationChapter 4. Introducing Oracle Database XE 11g R2. Oracle Database XE is a great starter database for:
Oracle Database XE is a great starter database for: Chapter 4 Introducing Oracle Database XE 11g R2 Developers working on PHP, Java,.NET, XML, and Open Source applications DBAs who need a free, starter
More informationThreads. CSE Computer Systems November 16, 2001
Threads CSE 410 - Computer Systems November 16, 2001 Readings and References Reading Chapter 5, Operating System Concepts, Silberschatz, Galvin, and Gagne Other References Inside Microsoft Windows 2000,
More informationuvi ... Universal Validator Interface Software Developers Kit Revision /29/04 Happ Controls
Happ Controls 106 Garlisch Drive Elk Grove, IL 60007 Tel: 888-289-4277 / 847-593-6130 Fax: 847-593-6137 www.happcontrols.com uvi Universal Validator Interface Software Developers Kit.......... Revision
More informationIntroduction to Computer Graphics (CS602) Lecture No 04 Point
Introduction to Computer Graphics (CS602) Lecture No 04 Point 4.1 Pixel The smallest dot illuminated that can be seen on screen. 4.2 Picture Composition of pixels makes picture that forms on whole screen
More informationGetting Started. 1 st Week, Sun-Jeong Kim. Computer Graphics Applications
OpenGL Programming Getting Started 1 st Week, 2008 Sun-Jeong Kim Visual Studio 2005 Windows Programming 2 Visual C++ Win32 Application New Project 3 Empty project Application Settings 4 Solution Prac01
More informationCalling stdcall and cdecl functions from DLLs and function pointers. (draft)
Calling stdcall and cdecl functions from DLLs and function pointers. (draft) ot4xb.dll provide support for calling function pointers, usually obtained from a DLl exported function, but also from a COM
More informationHands-On Lab. Multitouch Gestures - Native. Lab version: Last updated: 12/3/2010
Hands-On Lab Multitouch Gestures - Native Lab version: 1.0.0 Last updated: 12/3/2010 CONTENTS OVERVIEW... 3 EXERCISE 1: BUILD A MULTITOUCH APPLICATION... 7 Task 1 Create the Win32 Application... 7 Task
More informationกล ม API ท ใช. Programming Graphical User Interface (GUI) Containers and Components 22/05/60
กล ม API ท ใช Programming Graphical User Interface (GUI) AWT (Abstract Windowing Toolkit) และ Swing. AWT ม ต งต งแต JDK 1.0. ส วนมากจะเล กใช และแทนท โดยr Swing components. Swing API ปร บปร งความสามารถเพ
More informationA First Book of ANSI C Fourth Edition. Chapter 9 Character Strings
A First Book of ANSI C Fourth Edition Chapter 9 Character Strings Objectives String Fundamentals Library Functions Input Data Validation Formatting Strings (Optional) Case Study: Character and Word Counting
More informationUNIT -3 PROCESS AND OPERATING SYSTEMS 2marks 1. Define Process? Process is a computational unit that processes on a CPU under the control of a scheduling kernel of an OS. It has a process structure, called
More informationMultithreading Applications in Win32
Copyright, 2012 Multimedia Lab., Multithreading Applications in Win32 (Chapter4. Synchronization) Seong Jong Choi chois@uos.ac.kr Multimedia Lab. Dept. of Electrical and Computer Eng. University of Seoul
More informationFundamentals of Database Systems
204222 - Fundamentals of Database Systems Chapter 24 Database Security Adapted for 204222 by Areerat Trongratsameethong Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Outline
More informationIS311 Programming Concepts 2/59. AVA Exception Handling Jการจ ดการส งผ ดปรกต
1 IS311 Programming Concepts 2/59 AVA Exception Handling Jการจ ดการส งผ ดปรกต 2 Introduction Users have high expectations for the code we produce. Users will use our programs in unexpected ways. Due to
More informationMotivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4
Motivation Threads Chapter 4 Most modern applications are multithreaded Threads run within application Multiple tasks with the application can be implemented by separate Update display Fetch data Spell
More informationWe take a look at implementing some file menu options: New, Open, Save, Save As and Exit.
1 Programming Windows Terry Marris Jan 2013 7 Files We take a look at implementing some file menu options: New, Open, Save, Save As and Exit. 7.1 Header File The header file is largely unchanged from chapter
More informationบทท 4 ข นตอนการทดลอง
บทท 4 ข นตอนการทดลอง ในบทน จะท าการทดลองในส วนของซ นเซอร ว ดอ ณหภ ม เพ อผลท ได มาใช ในการเข ยน โปรแกรมและท าโครงงานให ได ประส ทธ ภาพข น 4.1 การทดสอบระบบเซ นเซอร ว ตถ ประสงค การทดลอง ว ตถ ประสงค ของการทดลองน
More information27 Designing Your Own Program
27 Designing Your Own Program 27.1 Using API s...27-2 27.2 Device Access APIs...27-19 27.3 Cache Buffer Control APIs...27-30 27.4 Queuing Access Control APIs...27-36 27.5 System APIs...27-39 27.6 SRAM
More informationCON34-C. Declare objects shared between threads with appropriate storage durations
CON34-C. Declare objects shared between threads with appropriate storage durations Accessing the automatic or thread-local variables of one thread from another thread is implementation-defined behavior
More informationChapter 4: Multithreaded Programming Dr. Varin Chouvatut. Operating System Concepts 8 th Edition,
Chapter 4: Multithreaded Programming Dr. Varin Chouvatut, Silberschatz, Galvin and Gagne 2010 Chapter 4: Multithreaded Programming Overview Multithreading Models Thread Libraries Threading Issues Operating
More informationClient and Server (DirectX)
Client and Server (DirectX) Vishnu Kotrajaras Server scalability Your game can handle more players at a time (Over internet, most peer-topeer can only handle about 6 players) All depend on server power
More informationMultitasking. Embedded Systems
Multitasking in Embedded Systems 1 / 39 Multitasking in Embedded Systems v1.0 Multitasking in ES What is Singletasking? What is Multitasking? Why Multitasking? Different approaches Realtime Operating Systems
More informationThree bailing programmers 1
Three bailing programmers 1 Three programmers go out on a boating excursion. A dark storm, violent waves, broken mast, lost sail and leaking boat. A boat, a set of oars, a bailing bucket, food and water.
More informationCS444 1/28/05. Lab 03
CS444 1/28/05 Lab 03 Note All the code that is found in this lab guide can be found at the following web address: www.clarkson.edu/class/cs444/cs444.sp2005/labs/lab03/code/ Threading A thread is an independent
More informationAn overview of how to write your function and fill out the FUNCTIONINFO structure. Allocating and freeing memory.
Creating a User DLL Extend Mathcad Professional's power by writing your own customized functions. Your functions will have the same advanced features as Mathcad built-in functions, such as customized error
More informationBroken Characters Identification for Thai Character Recognition Systems
Broken Characters Identification for Thai Character Recognition Systems NUCHAREE PREMCHAISWADI*, WICHIAN PREMCHAISWADI* UBOLRAT PACHIYANUKUL**, SEINOSUKE NARITA*** *Faculty of Information Technology, Dhurakijpundit
More informationCourse 3D_OpenGL: 3D-Graphics with C++ and OpenGL Chapter 1: Moving Triangles
1 Course 3D_OpenGL: 3D-Graphics with C++ and OpenGL Chapter 1: Moving Triangles Project triangle1 Animation Three Triangles Hundred Triangles Copyright by V Miszalok, last update: 2011-03-20 This project
More informationSOFTWARE ARCHITECT MICROSOFT CORPORATION BLOGS.MSDN.COM/MIKEHALL
MIKE HALL SOFTWARE ARCHITECT MICROSOFT CORPORATION MIKEHALL@MICROSOFT.COM BLOGS.MSDN.COM/MIKEHALL Windows CE Backgrounder Windows Embedded CE Architecture Real-Time Architecture Tools and Application Development
More informationDesigning Interactive Systems II
Designing Interactive Systems II Computer Science Graduate Programme SS 2010 Prof. Dr. RWTH Aachen University http://hci.rwth-aachen.de 1 Review: Conviviality (Igoe) rules for networking role of physical
More informationGame Programming Genesis Part II : Using Resources in Win32 Programs by Joseph "Ironblayde" Farrell
Game Programming Genesis Part II : Using Resources in Win32 Programs GameDev.net Introduction Game Programming Genesis Part II : Using Resources in Win32 Programs by Joseph "Ironblayde" Farrell Welcome
More informationMOBILE COMPUTING Practical 1: Graphic representation
MOBILE COMPUTING Practical 1: Graphic representation Steps 2) Then in class view select the Global, in global select the WINMAIN. 3) Then write the below code below #define MAX_LOADSTRING 100 enum Shapes
More informationHow to Talk To Windows. What did it say?
How to Talk To Windows What did it say? 1 DOS was essentially subservient. Your program was the master. When you wanted some service from DOS you called DOS it obeyed. You could even bypass DOS and communicate
More informationLecture 6 Register Transfer Methodology. Pinit Kumhom
Lecture 6 Register Transfer Methodology Pinit Kumhom VLSI Laboratory Dept. of Electronic and Telecommunication Engineering (KMUTT) Faculty of Engineering King Mongkut s University of Technology Thonburi
More informationINtime iwin32 Porting Guide
T E C H N I C A L P A P E R INtime iwin32 Porting Guide June, 2005 TenAsys Corporation 1600 NW Compton Drive, Suite 104, Beaverton, OR 97006 USA +1 (503) 748-4720 fax +1 (503) 748-4730 www.tenasys.com
More information2. On the main menu, click File -> New... or File -> New -> Other... Windows Fundamentals
Windows Fundamentals http://www.functionx.com/win32/index.htm http://www.functionx.com/visualc/index.htm Introduction to windows Overview Microsoft Windows is an operating system that helps a person interact
More informationDLL Injection A DA M F U R M A N EK KON TA MF URMANEK. PL HT T P :/ /BLOG. A DAMF URM ANEK.PL
DLL Injection ADAM FURMANEK KONTAKT@ADAMFURMANEK.PL HT TP://BLOG.ADAMFURMANEK.PL Agenda What and Why Preliminaries How + Demos Summary 5/9/2018 5:24:18 PM ADAM FURMANEK DLL INJECTION 2 What and Why 5/9/2018
More informationModule 3: Kernel Features
Module 3: Kernel Features Contents Overview 1 Definition of Real Time 2 Windows CE Kernel Features 4 Handling Processes, Threads, and Fibers 6 Protecting Applications 17 Synchronization Objects 23 Memory
More informationANKARA UNIVERSITY COMPUTER ENGINEERING DEPARTMENT BLM334-COM334 PROJECT
ANKARA UNIVERSITY COMPUTER ENGINEERING DEPARTMENT BLM334-COM334 PROJECT Due date: 08.05.2013 Lab Hours You re expected to implement Producer-Consumer Problem that is described below. (Any form of cheating
More information