failing like never before

14May/130

College Career Fairs for Engineers

We all know the career fair drill, you push your way through a mass of humanity to stand in line for a company that you hope will offer you a job. After five or ten minutes of waiting, you finally get to yell at an engineer over the din of hundreds for a few minutes, barely enough time to introduce yourself, get asked a few questions, and maybe even ask a few questions yourself. Hardly enough time to make a lasting impression. I attended a few college career fairs earlier this year while recruiting for my company, and throughout the process I realized that a vast number of students were completely misusing their oppertunities at the fairs.

Now, college career fairs present a fantastic opportunity for students. Whereas applying to a job online simply places your name into a bucket with dozens, if not hundreds, or even thousands of faceless applicants, a career fair allows students to cut through the HR and automated resume screener bullsh*t and immediately talk directly with a real life engineer, thereby allowing the student to show off their skills and express their interests. The importance of this opportunity cannot be overstated.

When I was a student, I had a few companies start scheduling me for interviews on the spot when I impressed their engineers at the fair. Now this isn't my company's style, but for a few people, I've scribbled on the back of their resumes phrases such as, "AWESOME, HIRE HIM NOW," and "AMAZING!!." I can assure you those resumes went to the top of the list.

5Jan/101

Back to School

Last quarter was probably my worst quarter ever. So of course, I have resolutely set out to change my habits and turn my academic performance around. Of course, its only the second day of school now, but I think my first day of class was exciting enough to deserve some blogging.

This quarter is momentous as it marks the first time in a year that I have enrolled in a non-engineering course. In this case, I'm currently enrolled in a statistics and a math class (among other classes). So the thing that astounded me upon first walking into my statistics classroom, was that there were girls in my class, more specifically, there were a lot of girls in the classroom (around 50%). This is in stark contrast to most of my engineering courses, where a classroom that is 20% female is considered to have an unusually high female to male ratio. I've had an electrical class with 14 guys and 0 girls, and a computer science class with 19 guys and 1 girl. Walking into my stats class, I felt as though I had entered another realm.

My first day proceeded to get more and more interesting. I spent fifteen minutes sitting in what I thought was my computer architecture class, before I realized that I was in the wrong class. Checking my schedule, I realized that my computer architecture class is on Tuesdays and not Monday (on the plus side, I was in the right room). Too embarrassed to push my way through the five people obstructing my path to the aisle, and walk out during the middle of class, I sat through the rest of the lecture, growing more and more confused about automata theory (a subject I was totally unqualified to understand).

But on the home front, I discovered that one of my roommates had left a pan of some sort of cooked food in the fridge over winter break, which meant that it was nearing almost four weeks old. So of course, the unidentifiable contents of the pan are now sporting a pretty coating of green and white mold. I stated how disgusting it looked and told my roommate that he should probably throw it out. Whereupon, he removed it from the fridge and placed it in the sink. The pan has since migrated to the countertop, and it appears that the green mold is now starting to outstrip the white mold (Go Green!). As of noon of today, the pan and its contents were still sitting on the countertop. Some part of me finds it extremely revolting, but another part of me is fascinated and wants to take pictures. I've decided to just not look at it until he throws it out.

9Jun/090

Network Timeouts in C

Reccently, while coding up some P2P sharing software for class, I came across a problem that really got me stuck. (Note, that I forked different processes to handle each upload and upload.) When reading data from another peer, my peer would generally have to block until the other peer responded, since with network programming we can never expect all of our requests to return immediately. The problem was that occassionally, the other peer would decide to die entirely and I was left with a process that would block essentially forever since the signal it was waiting for was never going to come. Now the great thing about blocking reads is that they don't burn CPU time spinning around in a circle waiting for data to arrive, but they do take up space in the process table and in memory. And of course, if my blocked reading proccesses stayed around forever, it would be very simple for a malacious peer to bring my OS to a grinding halt. Essentially, what I needed was a way to make read() timeout. Now anyone vaguely familar with using internet browsers and other such network-reliant programs are probably familar with timeouts, but I had no idea how to implement it in C.

My first thought, was to use setrlimit(), a Unix function that allows the programmer to set the maximum amount of system resources (CPU time, VM size, created file sizes, etc., for more use "man 2 setrlimit"). When setrlimit() is used to set a maximum amount of CPU time, the process will recieve SIGXCPU when the CPU time soft limit is reached, and then the process is killed when the hard limit is reached. At the time, I was a bit groggy so setrlimit() seemed like a great solution, but of course anyone with half a brain (which I apparently didn't have at the time) will realize that setrlimit() is definetely not the solution to this problem. A blocking process doesn't run and therefore doesn't consume CPU time, so setting a maximum CPU time does pretty much nothing to the blocking process; it'll still keep blocking forever.

After a little bit of trawling the internet, I finally came upon the perfect solution: alarms! When alarm(unsigned int seconds) is called, it will raise SIGALRM after so many seconds, realtime seconds mind you and not CPU seconds consumed by the process, even if the process that called alarm() is blocking. I set the alarm right before I began a read() and used signal() to bind a  signal handler to SIGALRM, so that when the alarm went off my signal handler could gracefully kill the timed-out download process!

7May/091

Something is Not Quite Right

Take a look at this C function, and see if you can can catch whats wrong with it. (That is, what about this function could produce an error?)

void wait_for_ready(void)
{
    while ((inb(0x1F7) & 0x80) || !(inb(0x1F7) & 0x40))
        continue;
}

This question showed up on my midterm and stumped the hell out of me at the time. Now that I know the answer, I feel like a complete idiot for not spotting the problem initially, seeing as its so amazingly obvious. When I took the exam, I spent way too much time on this problem, completely overthinking it.

In this function, we're using a machine level instruction, inb, to read the value of some hardware port on an x86 machines. So far so good, or so I thought when I was taking my exam. But the problem is, is that the data we're reading can be a shared resource, that is, other applications could be writing and reading to it at the same time, so a race condition ensues. Even on a machine with a single processor, this is still a problem, since wait_for_ready() could read the data memory into register, then a context switch could occur, some application could write to that location, and then wait_for_read() regains control but operates with an old data value.

So simple. And now I feel like an idiot.

10Oct/080

Weirdo Student

I'd like to describe a very brief dialogue that went on in my math lecture just this morning (about an hour ago). Mind you, my lecture has about 150 people in it, attendance is not taken and therefore not mandatory. For the sake of space, I shall refer to the weirdo student as WoS from this point forward. 

Prof: (after having explained a new concept) Are there any questions?

WoS: (raises his hand and is called on by the professor) Its more of an aside really, are you going to be letting us out early on Friday? 'Cause I have some business to take care of.

(Seriously, who the hell says, "I have some business to take care of?" Is he referring to Flight of the Conchords? "Its Business time!"  Although I seriously doubt it, WoS doesn't seem to be that kind of a person. Or perhaps WoS just really had to go to the bathroom. Anyway, I digress...)

Prof: If you have to go, just get up and go.

WoS: Oh, but you're such a great professor, I don't want to just leave.

Prof: If you have to go, just go.

At this point the professor continues on with the regular lecture.

I should probably point out, that in these large lectures, it is quite common for students to leave before lecture is over. Professors generally don't mind as long the student is discrete about it.

I'm pretty sure someone whispered that WoS was an asshole, right after the little dialogue was over. I personally would have called him a dumbass, but thats just me. WoS ended up staying for the whole lecture (maybe he peed in a cup) and as people were filing out, he said "OK, who was it that called me an asshole?" and managed to make a complete ass out of himself.

So well done WoS, well done.