Thursday, April 24, 2008

On Threading and Birthdays....

-
It was a long day. Today (as in April 23rd) was Sarah's birthday. Sarah being Lilly's best friend here in big D. Not ironically, Sarah is German. (She giggles pretty loudly whenever I speak German) She's from Hamburg in fact (and that is close to Bremon, which is where Lilly always says she is from...). Anyways, there was a birthday party, and it was fun.

Before that though was a long day at work. (It's amazing to me how, even though I generally have shorter work days than everyone else, they still feel really long... ) When I got there, the water was off. Apparently, a water heater in the building across the parking lot had "exploded". The city of Mesquite had apparently shut down the water as a result. Since, it turns out, there is only one shutoff valve for the whole building complex.....well, that's why we had no water.

Unfortunately, that was the most interesting part of the work day. The rest of the afternoon was spent working on our big, upcoming project. In working on it, I have, recently, been employing some new tricks.

It was not until recently that I had ever played around with threading. I had always kind of managed to avoid it, or to use systems which employed it without me having to do anything special. (I.e. Timer classes) This was only until recently though.

I had decided to write a program involving BSD sockets. (this is another programing facet I had never used directly before) So I set out to write a server. It didn't take long for me to realize that, in order to handle more than one connection at a time, I would need some way of making the program multitask. The server examples and tutorials I was studying generally just fork()'ed another process off, but they also mentioned that threading is better (just not within the scope of discussion in their document). Next thing I knee, I was embarking on a journey into the land of threads. These are actually very similiar to processes, but, whereas a fork() command generally creates a whole new process (think: program) containing a copy of the "parent" process in its current state, a thread exists inside the same program that created it, shares the same memory, and the same overhead. Both, however, allow a computer/program to multitask. So, I wrote a multithreaded server in C/C++. It mostly works... I'm having some issues reading the data from the connections, but that's all BSD socket issues. The threaded part works great.

So, how does this relate to work? Well, I started incorporating this threading stuff into my big C# project that we've been working on. The results have been astounding. The speed and functionality of the program have improved drastically. Now, I know that's not entirely an accurate statement because the program should still use the same number of clock cycles, but it certainly seemed better and faster. My boss was impressed by the difference. ( note: running this on a multi core or multi processor machine would increase the speed substantially since the program can actually take advantage of multiple processors/cores now. )

I like threading. I also like C#'s implementation of it. Easy and simple to use. You can even access instance variables from two threads in the same class!!! I don't think you can do that in C/C++.......

So, such is my life. Programing and birthdays. (there's another birthday party to go to for my friend, Merry, on Sat.!!)

I think I'm going to I to bed now though. Goodnight!!

sidenote: Daniel's got a great post about our government's propaganda machine over on his blog, including links to stories on the subject in such places as the NY Times and the Washington Post. It's pretty bad, and you need to be informed on this kind of stuff lest the Republican party (which is corrupt to the core right now!) lead us into a new Hitler like era of fascism.


Federal authorities are actively investigating dozens of American television stations for broadcasting items produced by the Bush administration and major corporations, and passing them off as normal news. Some of the fake news segments talked up success in the war in Iraq, or promoted the companies' products.

- Bush 'planted fake news stories on American TV' - The Independant


"Phase one: collect underpants. Phase two: [silence]. Phase three: profit!"

- Underpants Gnome - South Park

0 comments: