Posts

Leap years, lead seconds

Leap Year: Leap years are years with 366 days, instead of the usual 365. Leap years are necessary because the actual length of a year is 365.242 days, not 365 days, as commonly stated. Basically, leap years occur every 4 years, and years that are evenly divisible by 4 (2004, for example) have 366 days. This extra day is added to the calendar on February 29th. However, there is one exception to the leap year rule involving century years , like the year 1900. Since the year is slightly less than 365.25 days long, adding an extra day every 4 years results in about 3 extra days being added over a period of 400 years. For this reason, only 1 out of every 4 century years is considered as a leap year. Century years are only considered as leap years if they are evenly divisible by 400. Therefore, 1700, 1800, 1900 were not leap years, and 2100 will not be a leap year. But 1600 and 2000 were leap years, because those year numbers are evenly divisible by 400. Leap Second: A leap second is a s...

Callback into unloaded DLL

Often times you run into an issue where you get a callback into an already unloaded DLL. Following command reloads the symbols for the unloaded dll and gives you a nice stack.Very useful for programmers dealing with async multi threaded programs. .reload /unl unloaded.DLL

Byte Order Mark

I am in the process of implementing BOM support for our SOAP protocol. A BOM gives a hint on how to interpret the rest of the data. We are going to support following BOM FEFF UTF-16 BIG ENDIAN FFFE UTF-16 LITTLE ENDIAN FFBBFF UTF-8 The adjectives big-endian and little-endian refer to which bytes are most significant in multi-byte data types and describe the order in which a sequence of bytes is stored in a computer’s memory. Many mainframe computers, particularly IBM mainframes, use a big-endian architecture. Most modern computers, including PCs , use the little-endian system. The PowerPC system is bi-endian because it can understand both systems. The terms big-endian and little-endian are derived from the Lilliputians of Gulliver’s Travels , whose major political issue was whether soft-boiled eggs should be opened on the big side or the little side. Likewise, the big-/little-endian computer debate has much more to do with political issues than technological merit...

Ephermal ports

TCP Ports in the range 1024 to 5000 are used when a connection is made outbound from a machine. There are approximately 4000 of them. After the connection is torn down, the port is unavailable for a period of time greater than the max Time To Live (TTL) for IP packets on the network. The easiest way to check is to run “netstat /a /n” on the server. If all the ports in this range are in CLOSE_WAIT state, then the server can not make our bound calls (for instance to the DC to authenticate). MSDN has articles describing how to raise this limit. http://support.microsoft.com/default.aspx?scid=kb;en-us;812873

multi threaded programming

Every one says multi thread programming is hard. Here is a way I think to reduce the problem.   Understand what is the critical data you are trying to protect. Do you understand what happens if you just let different threads party on your data. If you do not understand this don’t go further.Understanding of this crucial in designing what kind of protection mechanisms you need. After doing analysis in above two steps its pretty clear what you need to protect. Single variable protection : An example of this is a state variable that can be set by multiple threads but you have a state machine to follow.This requires protection on this single variable to make we only do the valid transitions. Look at Interlocked* functions for this. Complex data structure : For ex a list that needs to be read and modified. For this you want to look at critical section that protects the data structure against multiple threads. More complex synchronization mechanisms include cross process coord...