Windows 7: Designing Efficient Background Processes

Report
PC19

Vikram Singh
Program Manager
Microsoft Corporation













Performance
• Responsiveness to the user
• Consumes resources from
foreground applications
• Boot, Shutdown, Logoff, etc.
Security
• Activity may require system
privileges
• Successful attack may
compromise entire system
Reliability
• Memory leaks
• System crashes, hangs
• Dependent application
crashes
Power Consumption
• Extra disk, CPU utilization
• Decrease in battery life
• Prevents idle efficiencies



required
Resource
Quantity
File I/O
47,286
Copy-on-Write (COW) Pages
4,656 (~18MB)
Memory Pages (Total)
15,967 (~60MB)
Registry Operations
38,508
Threads
367


50
40
30
20
10
0
Boot Time
Shutdown Time
seconds
seconds
24.7
46.1
Clean
IT
45
30
15
0
0%
Clean
IT
15 second trace
15 second trace
4%
30
Disk Read Count
Idle CPU Utilization
8%
25.6
40,000
1.01%
6.04%
Clean
IT
20,000
0
10,192
Clean
31,401
IT








Scheduled Task
Windows Service
• Continuous activity
from boot to
shutdown
• Service Control
Manager (SCM)
programming model
• Can specify
dependency
• Short
duration action
• Idle activity
• Take action
on user login
• Standalone
executable or
out-of-process
COM server
• Generally execute
in user session

Auto_Start






Auto_Start
Trigger-Start

Trigger










TabletInputService
Trigger-Start

Service Name
Description
Trigger Type
AELookupSvc
Processes application compatibility cache
requests for applications as they are launched
Custom ETW
BDESVC
Provides BitLocker client services for user
interface and auto-unlocking of data volumes
Custom ETW
BTHSERV
The Bluetooth service supports discovery and
association of remote Bluetooth devices.
Device
SensorsMTPMonitor
Monitors MTP (Media Transfer Protocol) sensors
(such as a cell phone with a GPS receiver) to
communicate sensor data to programs
Device
TabletInputService
Enables Tablet PC pen and ink functionality
Device
WinDefend
Protection against spyware and potentially
unwanted software
Group Policy


Trigger-Start




Demand_Start











[DllImport(“advapi32.dll”, SetLastError=true)]
Public static extern bool ChangeServiceConfig2(
IntPtr hService,
uint32 dwInfoLevel,
IntPtr lpInfo
);
Const uint32 SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6


// Example UPS Service
protected override void OnStart (string[] args)
{
IntPtr ServiceHandle;
IntPtr RequiredPrivilegesString;
// set required privileges
string RequiredPrivileges =
“SeShutdownPrivilege\0\0”;


RequiredPrivilegesString =
Marshal.StringToHGlobalAuto(RequiredPrivileges);
ChangeServiceConfig2(
this.ServiceHandle,
SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO,
RequiredPrivilegesString
);

}

Kernel





Detects Idle Condition
Task Scheduler
(schedule)
Launches Task
Power Efficiency
Diagnostics
(powercfg.exe)
































Trigger-Start
Auto_Start


http://go.microsoft.com/fwlink/?LinkId=128622

http://download.microsoft.com/download/9/c/5/9c5b21678017-4bae-9fde-d599bac8184a/Vista_Services.doc

http://msdn.microsoft.com/enus/library/ms685150(VS.85).aspx

http://msdn.microsoft.com/en-us/library/aa383614.aspx

http://www.microsoft.com/whdc/system/sysperf/perftools.
mspx




www.microsoftpdc.com
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market
conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.
MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

similar documents