| .NET Micro Framework multithreading explained |
Apr. 28, 2008
Microsoft's .NET Micro Framework (.NET MF) supports multithreading, just as its larger relatives, the .NET Compact Framework and .NET Framework do. A new posting on the .NET MF team blog reviews techniques for retrieving and setting thread priorities, scheduling threads, and suspending or stopping threads.
The .NET Micro Framework (.NET MF) has a memory footprint of only about 300KB, and it can run on an operating system or directly "on the metal" without one. Only one application can run at a time, but it can include multiple threads, Microsoft says.
In his post, Software Development Engineer Igor Grebnev begins by reminding readers that in .NET MF, thread priorities are relative to one another. A current thread's priority is calculated relative to the priority of the thread that executed the call to retrieve the property.
"As an example," Grebnev writes, "if a thread with Highest priority sets another thread's priority to Normal, the resulting thread priority will be Highest. This can be disconcerting when you're not used to it. The simple way to avoid problems with thread priorities is to always assign thread priorities from a thread that has a priority of Normal."
Assigning priorities to threads affects how those threads are scheduled, Grebnev explains. For example, if one thread is assigned a priority of Highest and the other is assigned a value of Normal, they get almost equal CPU time, except at the very beginning of execution. But, he adds, if there are two threads with the priorities of Highest and Lowest (the integer values 4 and 1, respectively) then the thread with Highest priority gets 2 times more CPU time than the thread with Lowest priority.
A "gotcha" cited by Grebnev is the fact that attempting to suspend a thread by calling the Thread.Suspend method will not stop the thread immediately. After the call, the thread is put into a "suspended" state, but will continue to execute until its time slice expires, which may take up to 20 milliseconds. Stopping a thread immediately can be done by calling Thread.CurrentThread.Sleep and passing it the value 0 in its parameter list, he writes.
.NET Micro Framework
 .NET MF grew out of Microsoft's work with "SPOT" Watches (Click for info) | Microsoft first released .NET MF in 2006, aiming it at wireless remote controls, watches, and other cost-sensitive devices with constrained processor and memory resources. The .NET MF grew out of Microsoft's Smart Personal Objects Technology (SPOT) initiative, with embryonic versions variously dubbed .NET Embedded and TinyCLR.
Ironically, Microsoft's SPOT watches -- later renamed Smart Watches with MSN Direct -- are no longer on sale. "We will maintain support of our watch customers and continue to deliver information to the watches," MSN Direct Program Manager John Canan wrote in a recent blog posting, "but we do not plan to increase our investment in the watch business going forward."
.NET MF, however, is alive and well. In February, Microsoft announced version 2.5, adding a native TCP/IP stack and support for Web Services on Devices (WSD), which aims to allow network-connected devices to discover and connect to one another without user intervention.
Further information
For further information on multithreading in .NET MF, read Igor Grebnev's posting on the .NET MF team blog, here. To read John Canan's farewell to SPOT watches, see his posting on SpotStop.com, here.
Related stories:
(Click here for further information)
|
|
|
7 Advantages of D2D Backup
For decades, tape has been the backup medium of choice. But, now, disk-to-disk (D2D) backup is gaining in favor. Learn why you should make the move in this whitepaper.
4 Legal Reasons to Control Internet Access
The Internet is obviously a valuable resource for many organizations. However, many are exposed to legal liability concerns because they fail to control Internet access. Learn if you're safe in this white paper.
Rapidly Resolve J2EE Application Problems
Whether you are in the process of building J2EE applications or have J2EE applications already running in production, you must ensure that they deliver the expected ROI. Learn how in this white paper.
Load Testing 2.0 for Web 2.0
There are many unknowns in stress testing Web 2.0 applications. Find out how to test the performance of Web 2.0 in this white paper.
Build Better Games Online
For the game infrastructure providers, life is complex. Making money from games has become more complicated. Why? Find out in this white paper.
Building a Virtual Infrastructure from Servers to Storage
This white paper discusses the virtual storage solutions that reduce cost, increase storage utilization, and address the challenges of backing up and restoring Server environments.
Gaining Faster Wireless Connections with WiMAX
Welcome to what is quickly becoming the hyperconnected world where anything that would benefit from being connected to the network will be connected. Learn more in this white paper.
Is Your Desktop a Security Threat?
The new wave of sophisticated crimeware not only targets specific companies, but also targets desktops and laptops as backdoor entryways into those business’ operations and resources. Learn how to stay safe in this white paper.
Increasing SAN Reliability by 100 Percent
Storage area networks (SAN) are a strong part of storage plans. Learn how to increase your reliability and uptime by 100 percent in this case study.
|
|
|
|
|