2001: I am sure that people are getting tired of hearing about multithreading, symmetrical multiprocessing, memory management, and preemptive multitasking. How is it really going to affect you, the Macintosh user, under Mac OS X, when you just want to read Low End Mac, check your email, and write a document.
Multithreading
Okay, what’s the deal on multithreading? What is a thread anyway?
Threads are instructions that are executed within the operating system or the application you are running.
In Blame It on Mac OS, I complained about how the current Mac OS will lock up when loading an MP3 file on my somewhat slow server. That’s because the Mac OS is single-threaded. I had two tasks fighting to take place at once. I was typing, and my MP3 file was loading. They were both attempting to use the same thread – the only thread – and so both were trying to be executed down the same pipe. It’s like two people trying drink from the same straw at the same time.
In a multithreaded environment, when my next MP3 was ready to be loaded, a separate thread would be spawned and would be its own independent entity.
What will really restrict you in a multithreaded environment is how much memory you have. More memory means that each thread can have some more space to work and accomplish it’s task quicker.
Symmetrical Multiprocessing
With the current Mac OS, multiprocessing is done asymmetrically. All of your tasks are done on one processor, and when that one has hit its maximum capacity, the operating system moves the task over to the other processor. When multiprocessing is done symmetrically all processors are acting as one, sharing the load.
When using a Symmetrical Multiprocessing operating system, applications don’t know that there are two processors instead of one. So if you get a really power hungry application, it’s going to go after everything it can, which means that it’s going to be using both CPU’s resources. With both processors working in conjunction with each other, you will notice a significant performance boost, because it will be getting the task done twice as quickly.
Memory Management
This is one of the biggest reasons why system administrators use Unix. We all know what happens when one of your applications in the current Mac OS crashes: You have about a 50/50 chance of having to reboot. What it comes down to is, “Did my crashed program manage to invade another one of program’s personal space?”
On a Unix system, each application gets its own block of memory and is confined to the particular area of memory that it’s assigned. If the application decides to crash, it doesn’t bleed over into the rest of your system. I would really hate to have to tell my boss, “We have to reboot the system because Jane’s server-based Word processor decided to crash.”
Having memory management does require some more horsepower when it comes to multitasking because the operating system has to seek out and allocate memory to an application on an as-needed basis. This can be very bad when something called a memory leak occurs, where an application has not returned memory it no longer needs and keeps asking for more. Your system will then slow down because you don’t have as much memory available because that one particular program is hogging it all because of a memory leak.
Preemptive Multitasking
Mac OS currently uses cooperative multitasking, which is where the current application you are working with has control over your CPU – and any applications you have sitting in the background take a back seat waiting for their turn to be allowed to do something. Most applications don’t take all of your CPU resources, so your background applications are still able to function, but they are handicapped because they are not getting the resources that they want.
An example of this is when I am downloading something in Internet Explorer on my Mac and switch to another application. The second I do that, my download speed drops quite significantly. That’s because the active application has just taken control of my CPU, and it decides to throw Internet Explorer a bone or two when it’s not doing anything too intense.
In a Unix Preemptive Multitasking environment, the operating system (or you) decides what gets to use what portion of your overall resources. If I am downloading from Internet Explorer and decide to launch my MP3 player, Internet Explorer still gets to keep all of its resources even though I am not actively in it.
Applications are also given priorities, so a system specific task would take priority over my word processor. If the system needs to display an alert, it would take priority over anything else that is happening.
One of the perks of priorities is that you can manually set priorities over anything you want. If I have 30 people trying to print to a printer on my Unix system, I can have my print jobs take priority over everyone else’s. Even though they sent in their request 10 minutes before I even hit the print button, I can tell Unix that I take priority over all other print jobs in the queue.
Should you be sharing applications from your system, you can cap the users accessing the application to how much of your resources you want them to use. You can also cap them on a user or group level.
If Jim only uses a word processor on my system to open small documents, I will only allow him 2% of my resources. But if Mary opens very large documents, I will give her up to 5% of my resources.
Setting priorities and resources manually can get very complex, so I only recommend doing so if you are running a Unix system as a server and need to do load balancing. I will say that it can be a lot of fun, especially when it comes to you getting your print jobs out before everyone else.
keywords: #unix #multithreading #multiprocessing #multitasking #memorymanagement