CS609 : System Programming

Course Overview

Course Synopsis

This course familiarizes you with the system programming basics with complete focus on the Microsoft’s Windows operating system. You will be able to know 32- and 64-bit architectures and what APIs are provided by the Microsoft Windows to write programs for these. In this course you will learn how Microsoft Windows handle files, memory management, error and exceptions, heaps, Dynamic Link Libraries (DLLs), processes threads, and various synchronization constructs.

Course Learning Outcomes

At the end of the course, you should be able to understand:

  • What is 32- and 64-bit source code and how Windows support these
  • What is Windows File and Directory Management system
  • How Windows report errors and its robust exception handling mechanism
  • What is Windows Registry and Registry Keys
  • Windows Memory Management through heaps
  • Dynamic Link Libraries (DLLs) and DLL Version Management
  • Window’s Processes and Threads management mechanism
  • Multiprocessing, Multithreading, and Parallel Processing in Windows
  • Synchronization constructs including Mutexes, Semaphores, Critical Sections etc.
  • Support of Windows for inter-process communication


Course Calendar

1 Windows Operating System
2 Windows Evolution
3 Windows Market Role
4 Windows, Standards, and Open Systems
5 Windows Principles
6 32-bit and 64-bit Source Code Portability
7 When to use Standard C Library for File Operations
8 A simple File Copy Program using Standard C Library
9 A simple File Copy Program using Windows API
10 File Copy Program using Windows Convenience Function
11 Windows File System
12 File Naming Conventions

13 Creating and Opening Files
14 Reading Writing a File
15 Closing File
16 Unicode and Generic Characters
17 Generic Functions
18 Unicode Strategies
19 Reporting Errors
20 Example: Reporting Errors
21 Standard IO Devices
22 Copying Multiple Files using Windows API
23 Encrypting Files
24 Windows File Management

25 Windows Directory Management
26 Console I/O
27 Printing and Prompting on Console
28 Printing Current Directory
29 64-bit File System
30 File Pointer
31 Arithmetic for File
32 Specifying File Pointer Position using Overlapped Structure
33 Getting File Size
34 Random Record Updates using File Pointer
35 File Attributes and Directory Processing
36 More on File and Directory Attributes

37 Temporary File Names
38 Listing File Attributes
39 Setting File Times
40 File Processing Strategies
41 File Locking
42 Releasing File Locks
43 Lock Logic Consequences
44 The Registry
45 Registry Keys
46 Key Management
47 Listing Registry Keys

48 Exception and their Handlers
49 Try and Except Blocks
50 Filter Expressions
51 Exceptions Codes
52 Exception handling sequence
53 Floating point exceptions
54 Errors and Exceptions
55 Treating errors as Exceptions
56 Termination Handlers
57 Better Programs with Termination Handlers

58 Filter Functions
59 Console Control Handlers
60 Console Control Handler Example
61 Vectored Exception Handling
62 Memory Management
63 Windows Memory Management Overview
64 Introduction to Heaps
65 Creating Heaps
66 Managing Heap Memory
67 Heap size and Serialization
68 Using Heaps
69 Working with Heaps

70 A binary search tree using Heaps
71 Memory Mapped Files
72 File Mapping Objects
73 Open Existing File Mapping Objects
74 Mapping Objects to Process address space
75 More about file Mapping
76 Sequential File Access using File Mapping
77 Sorting a memory mapped file
78 Using Based Pointers
79 Based Pointers: Example
80 Dynamic Link Libraries (DLLs)
81 Implicit Linking

82 Exporting and Importing Interfaces
83 Explicit Linking
84 Explicit Linking a File Conversion Function
85 The DLL Entry Point
86 DLL Version Management
87 Windows Processes and Threads
88 Process Creation
89 IDs and Handles
90 Specifying the Executable Image and the Command Line
91 Inheritable Handles
92 Passing Inheritable Handles

93 Process Identities
94 Duplicating Handles
95 Exiting and Terminating a Process
96 Waiting for a Process
97 Introduction to Environment Block (EB)
98 A Pattern Searching Example
99 Working in Multiprocessor Environment
100 Process Execution Times
101 Example of Process Execution Times
102 Generating Console Events
103 Simple Job Management shell
104 Get a Job Number
105 Listing Background Jobs

106 Finding a Process Id
107 Job Objects
108 Using Job Objects
109 Thread Overview
110 Thread issues
111 Thread Basics
112 Thread Management
113 Exiting Thread
114 Thread Identity
115 More on Thread Management
116 Waiting for Threads
117 C Library in Threads

118 Multithreaded Pattern Searching
119 Boss-Worker and Other Thread Models
120 MergeSort: Exploiting Multiple Processors
121 MergeSort: Threading Example
122 Introduction to Program Parallelism
123 Thread Local Storage
124 Processes and Thread Priority
125 Thread States
126 Mistakes While Using Threads
127 Timed Waits
128 Fibers
129 Fiber APIs
130 Using Fibers

131 Need for Thread Synchronization
132 A Simple Solution to Critical Section Problem
133 Volatile Storage
134 Memory Architecture and Memory Barriers
135 Interlocked Functions
136 Local and Global Storage
137 How to Write Thread Safe Code
138 Thread Synchronization Objects
139 CRITICAL_SECTION Objects
140 CRITICAL_SECTION for Protecting Shared Variables
141 Protect a Variable With a Single Synchronization Object

142 Producer-Consumer Problem
143 Sample Program for Producer-Consumer Problem
144 Mutexes
145 Mutexes, CRITICAL_SECTIONs and Deadlocks
146 Mutexes vs CRITICAL_SECTIONs
147 Semaphores
148 Using Semaphores
149 Semaphore Limitation
150 Events
151 Event Usage Models
152 Producer-Consumer Solution Using Events
153 Windows Synchronization Objects

154 Programming Guideline using Mutexes and CSs
155 More on Interlocked Functions
156 Memory Management Performance
157 Synchronization Performance Impact
158 Gauging Performance Impact of Synchronization
159 Performance Analysis of NS, IN, CS, and MX
160 False Sharing Contention
161 Tuning the Performance with CS Spin Counts
162 Setting the Spin Count
163 Slim Read/Write Locks (SRWs)
164 APIs for SRWs
165 Improved Locking through SRWs

166 Reducing Thread Contention
167 Semaphore Throttles
168 Thread Pools
169 Thread Pools APIs
170 Using Thread Pools
171 Alternate Methods for Submitting Callbacks
172 Process Thread Pool
173 Other Threadpool Callback Types
174 Locking Performance
175 Extended Parallelism
176 Parallel programming Alternatives
177 Parallelism Framework
178 Challenges in Parallelism Programming

179 Processor Affinity
180 Affinity Masks
181 Interprocess Communication
182 Anonymous Pipes
183 I/O Redirection using Anonymous Pipes
184 Named Pipes
185 Using Named Pipes
186 Creating Named Pipes
187 Named Pipe Client Connections
188 Named Pipe Status Functions
189 Named Pipe Connection Functions
190 Client-Server Named Pipe Connection