Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cs423-cotter1 Windows Operating Environment. cs423-cotter2 Windows Operating Environment 32 bit operating environment – Windows XP Microsoft Visual Studio.net,.net2005,

Similar presentations


Presentation on theme: "Cs423-cotter1 Windows Operating Environment. cs423-cotter2 Windows Operating Environment 32 bit operating environment – Windows XP Microsoft Visual Studio.net,.net2005,"— Presentation transcript:

1 cs423-cotter1 Windows Operating Environment

2 cs423-cotter2 Windows Operating Environment 32 bit operating environment – Windows XP Microsoft Visual Studio.net,.net2005, 6.0 STB Rooms 460, 462, 464 –75 machines – P4 class –Personal storage on remote machines Q: drive (60 MB), Y: drive (100MB) –Most programs on local hosts

3 cs423-cotter3 Windows Operating Environment Tools Available on SCE machines: –Web Browsers (Netscape, Explorer) –Business tools (MS Office) –Math tools (Maple, Matlab) –Programming tools ( MSVC++6.0, etc. ) –ftp –telnet –etc.

4 cs423-cotter4 Find IP Address of XP Machine Start -- Programs -- Command Prompt Brings up a text window At text prompt: route print C:\users> route print Active Routes: Network Address Netmask Gateway Address Interface Metric 0.0.0.0 0.0.0.0 134.193.2.254 134.193.2.253 1 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1 134.193.2.0 255.255.255.0 134.193.2.253 134.193.2.253 1 134.193.2.253 255.255.255.255 127.0.0.1 127.0.0.1 1 134.193.255.255 255.255.255.255 134.193.2.253 134.193.2.253 1 224.0.0.0 224.0.0.0 134.193.2.253 134.193.2.253 1 255.255.255.255 255.255.255.255 134.193.2.253 134.193.2.253 1

5 cs423-cotter5 Using ipconfig: Q:\>ipconfig Windows 2000 IP Configuration Ethernet adapter Local Area Connection: Connection-specific DNS Suffix. : ddns.umkc.edu IP Address............ : 134.193.2.253 Subnet Mask........... : 255.255.255.0 Default Gateway......... : 134.193.2.254 Q:\>

6 cs423-cotter6 Windows Programming Environment - MS Dev Studio

7 Visual Studio.NET

8 cs423-cotter8 Windows Programming Start New Project Microsoft Visual Studio.Net Start -- Programs -- MS Visual Studio -- MS Visual Studio To create a new project: –From Start Page: Create -- Project –Identify storage location for new project –Provide Project name –OK

9

10 New Project Window

11 cs423-cotter11 Windows Programming Add / Create files Project – Add Existing Item – C++ File Locate desired files. Repeat for all needed files For new files: Project -- Add New Item – C++ File Identify file.

12

13

14 cs423-cotter14 Windows Programming Add Libraries Project -- Properties linker tab -- category = Input -- add library names to “Additional Dependencies” for sockets, add “wsock32.lib”

15

16 Add Libraries

17 To support Multi-threaded Programs: Select Project  Program Properties Select C/C++ tab –Code Generation subtab Runtime Library item: –Default is “Single-threaded Debug (/MLd)” –Select “Multi-threaded Debug DLL (/MDd)”

18

19

20 cs423-cotter20 Windows Programming Select Active Configuration Two compile configurations available –Release –Debug Build – select “Configuration Manager” Select either Debug or Release –Note that debug versions create large (megabyte) files.

21

22 Active / Debug Configuration

23 cs423-cotter23 Windows Programming Build and Execute Project Build -- Build “project_name” Check message window for compile and link status. If no errors are indicated, execute program. Debug – “Start Debugging” or “Start Without Debugging”

24

25

26 cs423-cotter26 Windows Threads Similar in concept to processes, but designed to identify multiple activities that can be scheduled independently. All programs have at least 1 thread -- main ( ) program Any thread can create new threads.

27 cs423-cotter27 Windows Threads In C language (console mode): unsigned long _beginthread ( void(_cdecl *start_address)(void *), unsigned stack_size, void *arglistv ); Required Header: Required Libraries: LIBCMT.LIB or MSVCRT.LIB

28 cs423-cotter28 _beginthread ( ) void(_cdecl *start_address)(void *), –Start address of the routine that will begin the thread –The routine must have no return value unsigned stack_size, –Provide either a stack size for new thread or, if value is 0, use the same stack size as “parent thread” uses. void *arglist –Address of data item passed to new thread or NULL if nothing passed

29 cs423-cotter29 consum.cpp - multithreading #include voidaddem(void *); int main(int argc, char *argv[]) { int number = 4; _beginthread( addem, 0,(void *)&number); number++; addem(&number); return 0; }

30 cs423-cotter30 consum.cpp - multithreading void addem(void * vcount) { int i, count, sum; sum = 0; count = *(int *)vcount; for (i=0; i<=count; ++i) { printf("The value of i is %d\n", i); fflush(stdout); sum += i; } printf("The sum is %d\n", sum); fflush(stdout); }

31 cs423-cotter31 consum.cpp - Results The value of i is 0 The value of i is 1 The value of i is 2 The value of i is 3 The value of i is 4 The value of i is 5 The sum is 15

32 cs423-cotter32 consum2.cpp - multithreading #include voidaddem(void *); int main(int argc, char *argv[]) { int number = 4; _beginthread( addem, 0,(void *)&number); Sleep (100L); number++; addem(&number); return 0; }

33 cs423-cotter33 consum2.cpp - multithreading void addem(void *vcount) { inti, sum, count; count = *(int *)vcount; sum = 0; for (i=0; i<=count; ++i) { printf("The value of i is %d\n", i); fflush(stdout); sum += i; } printf("The sum is %d\n", sum); fflush(stdout); }

34 cs423-cotter34 consum.cpp - Results The value of i is 0 The value of i is 1 The value of i is 2 The value of i is 3 The value of i is 4 The sum is 10 The value of i is 0 The value of i is 1 The value of i is 2 The value of i is 3 The value of i is 4 The value of i is 5 The sum is 15

35 consumfloat.cpp #include,, voidp_func(void *); int flag; int main(int argc, char *argv[]) { floatnum, num2; num = 9.0f; num2 = 12.0f; flag = 0; _beginthread(p_func, 0, (void *)&num); while (flag == 0) ; p_func((void *)&num2); return 0; } cs423-cotter 35

36 consumfloat.cpp void p_func(void * vcount) { float *numptr; int number, i, prod; flag = 1; numptr = (float*) vcount; number = (int) *numptr; prod = 1; for (i = 1; i <= number; i++) prod = prod * i; printf("The number is %d\n", number); printf ("The factorial product is %d\n", prod); printf("The float is %5.2f\n", *numptr); fflush(stdout); } cs423-cotter36

37 Consumfloat.cpp Results The number is 9 The factorial product is 362880 The float is 9.00 The number is 12 The factorial product is 479001600 The float is 12.00 Press any key to continue...

38 cs423-cotter38 Summary Many Windows Integrated Development Environments (IDEs) available to develop C++ programs. –UMKC Labs provide Microsoft Visual Studio Multi-threading supported in Windows IDEs. –Just remember to correctly load the correct runtime libraries.


Download ppt "Cs423-cotter1 Windows Operating Environment. cs423-cotter2 Windows Operating Environment 32 bit operating environment – Windows XP Microsoft Visual Studio.net,.net2005,"

Similar presentations


Ads by Google