Payday loans
Auto insurance

Archive forOctober, 2003

Counting threads

You learn something new every day. (If that’s not true, it’s time to change jobs.) Today, among other things, I learned that calling the Mach task_threads API on the current task returns a list of threads that must be deallocated with mach_port_deallocate to avoid leaking Mach ports (and therefore to avoid leaking wired memory).

In other words, if you’re using Mach APIs to count the number of threads currently running in the current process, this is the correct way to avoid leaking memory:

unsigned int numThreads;
thread_array_t threads;
kern_return_t result;
int i;

result = task_threads(mach_task_self(), &threads, &numThreads);
if (result == KERN_SUCCESS) {
	for(i = 0; i < numThreads; i++) {
		mach_port_deallocate(mach_task_self(), threads[i]);
	}
	vm_deallocate(mach_task_self(), (vm_offset_t) threads,
	              numThreads * sizeof(thread_t));
	printf("Number of threads: %u\n", numThreads);
}

Comments off

Southwest flies to Philly!

Southwest Airlines will start flying into Philadelphia in May. Wow! It’s always been so expensive to fly into Philadelphia because about 60% of the airport’s traffic is from U.S. Airways. Southwest brings both a terrific airline and serious pricing competition to the airport at the same time. That’s absolutely wonderful news for the Philadelphia airport, and, depending on what the routes are — they won’t be announced until December — it may make going home a lot easier.

Comments (3)

Rotor on Panther update

Ted Neward talks about the Rotor BOF held at Microsoft’s PDC last night and mentions the challenge of getting Rotor to work on Panther. For what it’s worth, the FreeBSD 5 connection doesn’t really make much of a difference in updating Rotor for Panther. Rotor’s BSD layer — the PAL — already works. The biggest problem with Panther (and with moving Rotor to any new OS release) is the change in compilers and low-level system libraries.

I believe I’ve fixed most of these problems, but I’m having serious trouble with precompiled headers. I’m not sure that Rotor’s precompiled header support, which is specific to GCC 3.1’s PFE on Jaguar and not supported anywhere else, can be updated for GCC 3.3’s PCH. I may just change Rotor to build without precompiled headers on Panther as a way of getting things working quickly. It’ll build a lot slower, but I’m not sure when I’ll have time to get PCH to work.

Comments off

Release JNib?

I’ve had two requests from people at prominent companies in the past few weeks for copies of JNib, which I wrote as a MacHack hack in 2002. JNib is a set of Java classes that translate Carbon nib files into a Swing UI at runtime, much as IBCarbonRuntime translates the same nibs into a Carbon UI. In other words, it accomplishes a couple potentially useful things:

  • You can create a UI for a Java application in Interface Builder.
  • You can use nib files on Windows.
  • Java applications that use it may come closer to following the Aqua HI guidelines for control spacing than Java applications built without it.

I’m wondering if I should release the code on SourceForge or something like that. The catch is that I really don’t have time to support it, add features, or fix bugs. But given its potential usefulness, perhaps somebody else would be willing to own the project.

Any thoughts, comments, or suggestions?

Comments (6)

Panther!

Panther was released tonight. I wandered by the Valley Fair store just after 8 to see what an OS release event was like. (I was in Washington for the Jaguar release, before Washington had an Apple retail store, and the earlier Mac OS X product launches came before the Apple retail stores existed.)

Wow, was that fun. I didn’t get home until 2 a.m., after a bunch of us who stayed until the store closed at midnight finally finished dinner. It’s just so amazingly wonderful to see tons of people — particularly people who don’t use computers for a living — who are really excited about buying and using a product that you’ve helped create. Admittedly I only had a very small impact on Panther — I basically just tweaked it a little here and there — but I’m proud of my contributions. It’s a terrific operating system release. It’s fast, it’s powerful, and it has tons of new features. The marketing folks must have simplified a lot to get the list down to 150.

Anyway, I had a blast tonight answering questions and talking to people about all of the cool stuff in Panther. I’m really looking forward to doing that again for the next OS release.

Comments (4)

Looks like I’m infected

Chris Hanson says that nobody should go “near” Microsoft’s shared source code. To quote him: “Stay far, far away from any Microsoft source code if you want to have a future in software development.” I have a lot of respect for Chris, but I really have to take issue with this.

Y’see, some of the code he’s talking about is code that I wrote. I’m somewhat inclined to think that I have a future in software development. At least, I hope so. Apple certainly didn’t seem to think that my having worked on a successful shipping product would be a problem in hiring me.

His argument is rather misguided. He twists Microsoft’s dislike for its employees using GPL’d code into some sense that the company is going to sue people who have merely looked at Microsoft’s code. A doesn’t imply B here at all. There’s simply no connection whatsoever.

The problem that many companies (Microsoft isn’t the only one) have with the GPL is that many of its parts are legally vague. The FSF certainly has its views of what the GPL means, but the license has never been tested in court, so there’s no guarantee that the provisions are enforceable in exactly the way the FSF intends. The license may be stronger than the FSF thinks or it might be weaker. Nobody can be sure. That vagueness makes lawyers afraid, and frightened lawyers produce strict policies. If Microsoft employees can’t look at GPL’d code, that’s probably the reason why. (Oh, and Chris, please don’t take the comments of one random Microsoft employee as company policy. You wouldn’t [and shouldn't] take my comments as Apple policy, right?)

None of that has anything to do with the license for code that Microsoft releases under its variety of “shared source” licenses. As with any company, if Microsoft chooses to release source code it can do so under whatever license it wants. In the particular case of Rotor, there’s no nondisclosure agreement that you need to sign before accessing the code and there’s no trade secret protection for the code. The license allows you to use Rotor itself for whatever non-commercial purpose you want. In addition, there’s this very important clause:

You may use any information in intangible form that you remember after accessing the Software. However, this right does not grant you a license to any of Microsoft’s copyrights or patents for anything you might create using such information.

In other words (and I’m not a lawyer; get one if you need one), you can read the code without being “contaminated” by some sort of all-knowing evil Microsoftian pixie dust. You can’t copy the code directly, but the same applies to GPL’d code (unless your product is itself GPL’d). And you aren’t granted a license to Microsoft’s patents by virtue of reading the Rotor code, but the same is true for BSD-licensed code.

In short, read the license for any source code you want to read and make sure you understand it. Don’t listen to shrill arguments about licenses that are stated in vague generalities, whether about the GPL, the BSD license, or any of Microsoft’s shared source licenses. And if you’ve read the Rotor code in depth, you understand it, and you’re looking for a job, send me your résumé. Anyone who can understand how a complicated virtual machine works is probably smart enough to have a good future in software development.

Comments (3)

Free speech and the Pledge of Allegiance

I was planning to go to sleep earlier than normal so I could be sure to be at work in time to see a little event tomorrow morning, but Chuq just posted something that I feel compelled to respond to.

He’s ridiculing the Pledge of Allegiance case that the Supreme Court just decided to hear, casting the issue as one of a minority group, atheists, trying to assert their free speech rights over the rights of the rest of the country.

The problem with that argument is that this isn’t a free speech case. If I choose to say the Pledge with “under God” in it, I’m allowed to do so, and if I choose to say it without those words, I can also do so. In fact, students in a class can choose to say it either with or without the words today…or with any other words, or none at all. None of that is at issue in this case.

Instead, this is a freedom of religion case. The First Amendment mandates the separation of church and state. Newdow, the plaintiff, is arguing that the presence of the words “under God” in a phrase that is repeated in an official ceremony (not much of a ceremony, admittedly, but one nonetheless) is effectively an establishment of religion by the government. He isn’t asking that everyone be banned from saying the Pledge; after all, it’s just a series of (non-obscene) words. Anyone can say them whenever and wherever they want (subject to standard restrictions of freedom of speech…perhaps you couldn’t yell the Pledge in a crowded theater or something like that). He’s arguing that the Pledge shouldn’t be an organized part of his daughter’s education as long as it keeps its current words.

It’s a case that’s rather reminiscent of Abington School District v. Schempp, the landmark 1963 case in which the Supreme Court ruled that mandatory daily Bible readings in public school were an unconstitutional government establishment of religion. My mother was a student at Abington at the time, and I have to say I can’t even imagine what it must have been like for her, as a Jewish girl, to have to read from the King James Bible and recite the Lord’s Prayer every day. Even if she had been allowed to sit in silence or leave the room while the rest of her class did the reading, the ceremony itself said that she and her faith were not really a part of what the school stood for.

Forty years later, it’s easy for us to look back at Abington and claim that the court decision was obvious, that it’s unquestionably wrong for non-Christian students in a public school to have to read from the Christian Bible every day…or to be ridiculed or punished when they choose not to participate. At the time, though, the decision was extremely controversial. Members of Congress immediately started work on a constitutional amendment to override the Court. As the months and years went by and the apocalypse failed to materialize, support for an amendment eroded. I’m glad that my only exposure to the Bible in my public school education was from discussions of history and comparative religion.

It’s easy to dismiss Michael Newdow as an anti-religion nut case, or, as Chuq says, a representative of a group of capital-A “Atheists”. Newdow is not the best plaintiff to bring this case. I’m sure the attorneys who will argue his side would have preferred a nice all-American family that happens not to believe in God, or a Buddhist family, or the concerned parents of a teenage daughter who has taken to paganism and been subjected to teasing and harassment for her beliefs. You play the hand you’re dealt, and since Newdow filed the case himself, he’s all his side’s got.

Will the Court rule in Newdow’s favor? Who knows. I won’t be surprised if they remand the case, saying he doesn’t have standing. Whether you agree with him or not, though, this is an interesting case, and it’s certainly not a slam dunk in either direction. It’s also definitely not an attempt to assert some vague rights, nor is it an attempt to ban potentially offensive speech. It’s simply a question of whether the recitation of “one country, under God” as part of a school ceremony is a government establishment of religion. Of course, if the answer was as simple as the question, we wouldn’t be arguing about it.

Comments (2)

Networking again

A few days ago, I mentioned that I’d been having some horrifically complicated wireless networking problems with one particular PowerBook at home. In the middle of a random conversation at work today, someone mentioned KisMAC. KisMAC is typically described as a wireless stumbler — a program that helps you discover wireless networks — but it turns out that it’s great for wireless network troubleshooting, too.

I ran it and something jumped out right away. My base station was cycling through wireless channels — 10, then 11, then 9, then back to 10 — and another access point was cycling through exactly the same channels in exactly the same order, just a fraction of a second behind mine. The other access point was for a network that I’d never seen before; it doesn’t show up in my AirPort menu. I looked at the networks listed in KisMAC, saw that nobody was using channels 2, 3, or 4, and set my base station to channel 3. (I would’ve set it to Automatic, but this is a first-generation base station, so it doesn’t have that option.) I restarted the base station, and everything’s been working great ever since.

I don’t know a thing about 802.11b channel selection algorithms, but it sure seems like something wasn’t working correctly here. Maybe it’s just that my base station’s quite old — two and a half years! — but maybe not. Anyway, it works now, and I know what to try if I ever see anything like this again.

Comments (2)

Foo Camp

Chuq and others have written quite a lot about the O’Reilly “Foo Camp” held this weekend in Sebastopol. It sounds like a lot of fun. I wish I could’ve been there, but I didn’t get an invite this time around. Nor, it seems, did many people my age, so I can’t really complain. And it’s not like I can talk about what I’m working on anyway, so I would’ve been leeching off of everyone else there without adding much of my own. Oh, well. Maybe next year….

On a semi-related note, Foo Camp sounds like it was a non-Mac-specific version of MacHack. It had people with very diverse interests, participant-organized presentations, an informal setting, and a whole bunch of fun mixed in. I wonder if part of the idea came out of Tim O’Reilly’s MacHack 2002 keynote. If so, I’m glad to see the MacHack spirit spreading. With the right set of participants, it really does make for a terrific conference.

Comments (3)

Networking problems

About a week ago, my PowerBook started to have some interesting networking issues. I’d be merrily browsing the web, and all of a sudden nothing would load. I’d fiddle with various settings and then everything would be back to normal. After fifteen minutes or so, it’d break again. Meanwhile, my work PowerBook — the exact same model — was sitting right next to the problematic PowerBook and doing just fine. Restarting didn’t fix the problem.

After a lot of fiddling with things, I found that I could restore my network connection by pinging my router. My networking setup is a little complicated, but not too bad. I have a Comcast cable modem, which is connected to an eight-port 10/100 Netgear hub. My computers all use AirPort to connect to a first-generation AirPort base station, which is plugged into the hub. The base station is set up to do bridging, so it should just be passing everything through to the hub, which just passes things on to the modem. Comcast hands out as many IPs as I have computers (I’ve had up to five so far), so the router is a Comcast system somewhere upstream. When my PowerBook is in this state and I ping the router, the first packet is always dropped but subsequent packets get through.

Since this started just after I installed the reposted version of Mac OS X 10.2.8 and some people claim that 10.2.8 causes everything from crop failures to rains of frogs, I figured I’d reformat and try a newer version of the OS, only preserving non-networking settings. That didn’t change the behavior, either. I’d still lose my network connection every few minutes until I pinged the router, and then all would be well for another few minutes. I tried restarting the cable modem and the base station, but that didn’t change anything.

Baffled, I brought my PowerBook in to work to try it on Apple’s wireless network. Everything worked fine.

I brought the PowerBook back home and played with the settings on my base station. I turned on WEP, set a password, and reset the base station. No change in behavior.

Today, I dug up a sufficiently long Ethernet cable, turned off AirPort on my PowerBook, and plugged the PowerBook straight into the hub. Everything has worked great for hours on end now.

That pretty much seems to pinpoint either the base station or the PowerBook’s AirPort card as the source of the problem. The card worked fine in the office, though, and the base station is continuing to serve multiple other computers with no trouble at all. There’s one other interesting tidbit — throughout all of this, I always received the same IP address from the router when connecting via AirPort. When I connect with the wired connection, I get a different IP (presumably because the MAC address of the Ethernet card is different from that of the AirPort card).

I’m confused. I’d like to avoid buying either a new AirPort card or a new base station, and I’d like to avoid disassembling the PowerBooks to swap AirPort cards and see if the problem switches to the other PowerBook, but I’m not sure what else I can do. At least I sort of have things working for now, but having an Ethernet cable stretched across the living room floor isn’t really ideal….

Comments (2)

« Previous entries

google