Lab 2-2: Exploring Threads Objectives Prerequisites After completing this lab, you will be able to: Add profiling support to a Windows CE OS Design Locate files associated with Windows CE profiling Operate Windows CE Remote Kernel Tracker Before working on this lab, you must have: Completed Lab 2-0: Minimal Kernel Configuration Completed Lab 2-1: Exploring Memory, Heaps, and Stacks Estimated time to complete this lab: 30 minutes
2 Lab 2-2: Exploring Threads Lab Setup This lab assumes that: You selected the Emulator microprocessor when you installed Platform Builder You installed Platform Builder in the default directory provided by the Platform Builder Setup program You completed Lab 2-1 and have the completed workspace from that available.
Lab 2-2: Exploring Threads 3 Exercise 1 Add Kernel Profiling support The default Platform Build Options initially set by New Platform Wizard disables Kernel profiling (A.k.a. event tracking). Adding Kernel profiling support will permit detailed Kernel information to be logged and viewed. Set Platform Build Options From Platform Builder Platform Settings and click Build Options tab. Click Enable Profiling (IMGPROFILER=1) until Check mark appears. Click OK button to save changes. Build an OS image 1. From Platform Builder Build OS Clean Before Buiding (Alt-UC). 2. From Platform Builder Build OS Sysgen (Alt-US).
4 Lab 2-2: Exploring Threads 3. Watch the status bar in the lower right corner of the Platform Builder window for the current state of its Status Monitor. It reports the state of the build process and your target device: 4. When the Status Monitor shows the Build status as Not Building, it has finished building the image: 5. Verify this build generated no error(s): You can now download the image to the CE Device. Start CD Device 6. From Platform Builder Target menu, launch Attach Device (Ctrl+Shift+D).
Lab 2-2: Exploring Threads 5 Note You can move or minimize the Emulator window, but you should not close it until instructed to do so. 7. Watch Status Monitors at lower right corner of the Platform Builder window for Target Message Output, CESH Target Control, and Kernel Debugger: Windows CE boots up and runs just as before with the same number of processes, threads, and modules. What is different this time is the profiling data structures included.
6 Lab 2-2: Exploring Threads Exercise 2 Remote Kernel Tracker Launch Remote Kernel Tracker 1. From Platform Builder Tools Remote Kernel Tracker. Click Default Device and Click OK button.
Lab 2-2: Exploring Threads 7 2. Remote Kernel Tracker will establish a Platform Manager connection with the CE Device and download a number of its files that are loaded into memory (CEMGRC.EXE and RTH.EXE) in order to start logging events to the host. Click button to toggle Show/Hide Legend mode: Click here Events occurring in the CE Device are continuously being logged first into its local memory. CeLogFlush.exe then periodically transmits it to the host via its Platform Manager connection for Remote Kernel Tracker tool to display.
8 Lab 2-2: Exploring Threads Click button to refresh the logging data being displayed and note the timeframe increasing as new data is being added to the right. Click button to search for an event by type or by a particular process or thread, etc.
Lab 2-2: Exploring Threads 9 Exercise 3 Logging a Simple Application Before looking at the complex relationships between multiple threads, this exercise will look at the logging data being generated for a simple application (created in Lab 2-1). Remove all breakpoints (just in case) From Platform Builder menu select Edit Breakpoints to open the Breakpoints List Window. Click Click button to delete all breakpoints. to close the Breakpoint List window. Launch app2_2a.exe application 1. From Platform Builder Target Run Programs to open the Run Program window. Click app2_2a.exe to select. Click Run to launch program. 2. Verify the app2_2a.exe application is loaded into the CE Device and runs to completion while Remote Kernel Tracker is running: 3. Verify the app2_2a.exe application load and unload events on the CE Device appears as Remote Kernel Tracker activity:
10 Lab 2-2: Exploring Threads 4. Move the cursor over events in the Remote Kernel Tracker display to see more details popup regarding each event: Position the mouse over the red square for a few seconds to see a popup for more details on the load module event. Position the mouse over the green lines for a few seconds to see a popup for more details on the Process Info. Click on an event to set the cursor to assist in zooming and stepping through events and threads using menu buttons. Change the Zoom Range to view thread transitions in more detail. Take some time to explore the information provided by the kernel tracker to see how it shows the thread transitions and the reasons for them.