Saturday, June 28, 2008

Processor support for 64 bit?

While chatting with a friend online the other day I became curious how one would determine if a processor supports 64bit and if the kernel is 64bits. Know the answer to first question could have helped me out a few weeks ago when I tried to install the x86_64 version of Fedora 9 on my wife's laptop. Unfortunately when I booted the install disk, the installer message stated that it was not 64bit capable.

To determine if you processor supports 64bit mode in Linux, the easiest thing to do is:
grep lm /proc/cpuinfo

The lm stands for long mode and it's in the cpu flags section. If more than one line is returned with the same information, the processor has multiple cores.

To determine if the OS kernel what instruction set it is running use:
uname -m

A value of x86_64 indicates that it is running the 64 bit extensions for Intel/AMD.

Thursday, June 26, 2008

Could not chdir to home directory /home/xxx

I recently installed Fedora 9 x86_64 on my home machine. This is the first time that I've run the 64 bit version. I didn't disable SELinux this time either.

I've got most things working well on the machine. The most annoying issue that I've had is when I used ssh to access my machine from somewhere else. Everytime that I logged in I would get the the following message and get dumped to the / directory.

Could not chdir to home directory /home/xxx: Permission denied

I could type cd and it would take me to my home directory. I could read files in those directories. Looking around I found that others were having problems but usually it was a pam problem or something else related to authentication. Eventually I decided that it was a SELinux issue.

Since I've never run SELinux on my machine, it stands to reason that none of the proper contexts were ever applied to the home directories. After digging around with google and figuring out what I needed I discovered the problem. Below is what my context looked like:

> ls -Zd *
drwx------ xxx xxx system_u:object_r:file_t:s0 xxx

I created another user and discovered that what it should look like is this:

drwx------ aaa aaa system_u:object_r:user_home_dir_t:s0 aaa

To change the context to be that I used:

>chcon -t user_home_dir_t xxx
> ls -Zd *
drwx------ xxx xxx system_u:object_r:file_t:s0 xxx

SELinux tended to be difficult to use. Fedora and the other distributions are working hard to make it easier to use. Consider leaving it enabled when working with newer distributions. It could prevent a zero day exploit from taking over your machine.

Sunday, May 18, 2008

New Railing and Storm Doors


We decided to put up railing last year. It's not required by code but we figured that it would help improve the look of the house and prevent any unwanted accidents. We wanted it to last but didn't want to spend a fortune for it. We finally settled on ColorGuard railing. Each piece of railing comes with everything that you need.

Some of the original posts had some rot on them. They looked nice but were not pressure treated. Two of them would have need to be replaced this summer no matter what. The posts were replaced with pressure treated 4x4 posts that had a vinyl sleeve placed over them.

New Larson Tradewinds storm doors were installed. These have the retractable screen. The door on the front of the house is a full view and the one on the back is a mid view. The retractable screen is nice since you can open the door at any time and pull down the glass to reveal the screen. There's no mess with the removing glass and installing the screen.

Here's the before pics.

The new look:

Monday, May 05, 2008

Family and Cancer

Lee Ann's cousin's wife has cancer. She has been documenting her progress on her MySpace site. She and her family are doing as well as can be expected. I can't even imagine what it must be like to deal with it.

The brother of my best friend from high school had his son diagnosed with Leukemia a couple of years ago. He's made it through the chemo and I believe that they have stated that it's in remission. Again, it's not a situation that's easy to imagine. There is a good documentary called A Lion in the House that appeared on PBS a couple of years ago that deal with children and cancer. It's probably one of the saddest things I've watched.

Sunday, April 13, 2008

Pthreads

I needed to learn a little about pthreads so that I could modify some code for work. Below is a sample program that does some basic counting in threads. I've used pthread_join to wait for the threads to finish. I did this because I wanted to signal to the threads when to finish. There's a global value, thread_exit, that is shared with the threads. Setting thread_exit = true signals all of the threads to exit. It is set after the program sleeps for 1 second.

If a thread needs to do a certain amount of work and finish during it's own time, a status flag could be passed into the thread. When the thread is finished, the flag would be set. This method is described in the pthread_join man page.

Numerous examples demonstrating the use of pthreads can be found using google.

Put iostream and pthread.h between the <>.

//============================================================================
// Name : pthread_test.cpp
// Author : James Hubbard
// Version :
// Copyright : Public Domain
// Description : Pthread Example
//============================================================================

#include <>
#include <>


using namespace std;
bool thread_exit = false;

void *thread_test(void *arg) {
int thread_num = *((int *)arg);
int *count = new int(0); //clean up elsewhere
while (!thread_exit) {
(*count)++;
//if ( !(*count%5000000) )
// cout << "thread " << thread_num << ": " << *count << endl;
}
cout << "Thread " << thread_num << " complete: " << *count << endl;
return (void *)count;
}

int main() {
int num_threads = 10;
pthread_t *thread_id = new pthread_t[num_threads];

cout << "Pthread Test" << endl;
for (int i = 0; i < num_threads; i++) {
int error = pthread_create (&thread_id[i], NULL,
thread_test, (void *)&i);
if (error)
cout << "Error: " << error << endl;
}

sleep(1);
thread_exit = true;
int *count_value[num_threads];

for (int i = 0; i < num_threads; i++ )
pthread_join(thread_id[i], (void **)&count_value[i]);

cout << endl;
for (int i = 0; i < num_threads; i++) {
cout << "main count " << i << ": " << *count_value[i] << endl;
delete count_value[i]; //cleanup counts from threads
}

delete thread_id;

return 0;
}

Monday, March 31, 2008

Outfoxed: Rupert Murdoch's War on Journalism

After watching the primaries this year it's obvious that all of the news agencies are biased. Fox News is just as bad. I have less faith in Fox News than I do in CNN. They are truly horrible. Without a doubt, they pushed other candidates aside to so that they would not have a chance. Ron Paul raised more money than any other Republican candidate directly from the people. At every turn he didn't get the coverage that he deserved.

Here's an interesting video on Fox News:
Outfoxed: Rupert Murchoch's War on Journalism

Update 1: Just so you know I don't really care for any of the news networks. This article by Chez should give you an idea of just how bad it is at CNN. I used to watch a lot of CNBC, but the housing crisis and current economic woes illustrates just how clueless they are. I find myself watching MythBusters and How it's Made on the Discovery channel more and more.

Update 2: Here's another example of why I don't watch CNBC, Larry Kudlow. He's one of those that has been talking up the economy. He's been calling it Goldilocks for more than 1.5 years now. During this time he's give Roubini and others that have been talking about how bad it was getting and is now the short end of the stick.

Kudlow is a real cheerleader for less gov't regulation and intervention. To a certain point I think less is more. The gov't economists really don't know how to model the economy. (It would be nice to have a scoreboard to see how badly they've done.) Almost all of the regulation seems to have come after major problems like Great Depression, Savings/Loan, Long Term Capital Managment, Dot.Com Bubble and now Subprime.

The Subprime problem has essentially fixed itself. The banks are scared, people now know not to buy a home they can't afford. (Keep on charging the card though.) The only reason to enact legislation now is to clean up some of the bad mortgage and loan procedures. It will also provide a reminder for later generations 40 years from now when they start doing stupid stuff again.

Wednesday, March 19, 2008

Your rental is being foreclosed

Quinn's situation isn't unique. It's happening in a lot of places. It's just a shock when someone you know is having it happen to them. What probably happened is that the owner took out a sub prime loan or took out too much equity thinking that he would be able to sell it at a profit. The housing market in HI is doing fine from the reports that I had been hearing, but it's not crazy. Local lenders had been more conservative as well. Most of the subprime problem in Hawai'i has been caused by outside lenders.

Update: Fix spelling mistake in title. Also note that it is Washington Mutual that owns the mortgage. WaMu is in trouble because of all of their subprime lending.