Phase Change Memory documentation

Regarding the project for the fall SDBS class in ITU of 2010.  I will list some resources that I found that could be helpful in completing the PCM part of the project (Question 2).  Though most of my list refers specifically to PCM, the file system and the operating system; I think the context given by these documents can potentially help in answering other questions in the project.

  1. The first Google hits are usually Wikipedia pages. Comments like “PRAM can offer much higher performance in applications where writing quickly is important, both because the memory element can be switched more quickly, and also because single bits may be changed to either 1 or 0 without needing to first erase an entire block of cells.” are relevant.  The whole “PRAM vs. Flash” section is giving a list of characteristics
  2. Numonyx is one of the pioneers of PCM.  Here is a cool video that contains an introduction to PCM.
  3. Cool article containing information about PCM.  While reading it you might also want to check out the referenced articles.
  4. A paper talking about how to design a File System for PCM.  This one has lots of ideas and clarified key concepts when I read it.
  5. A paper talking about characteristics of PCM.
  6. A paper talking about PCM & main memory.

Note that for 5 & 6 you need to download the pdf from the ACM digital library.  This might not work if you are not using the ITU network.  Hope this increases the helps some people.

Posted in PhD | Leave a comment

Sending mail from the console is cool! ssmtp with gmail.

Quick Cheat-sheet on configuring ssmtp on my machine.  This is really cool for me because it enables me to send git patches from console.  I confess, I like the console.

yum install ssmtp -y
cat << EOF >
root=postmaster
mailhub=smtp.gmail.com:587
Hostname=gmail.com
UseSTARTTLS=YES
AuthUser=username@gmail.com
AuthPass=YOUR_PASSWORD
EOF
ls -s -f /usr/sbin/sendmail.ssmtp /etc/alternatives/mta
Posted in commands | Leave a comment

Adding a printer CUPS & SAMBA

The IT University of Copenhagen has this printing system where you have a centralized server receiving all the printing requests.  I was having a hard time finding the way to configure my Fedora to talk to this server.  A colleague showed me that one can configure CUPS to talk Samba.  And coincidently, the ITU servers spoke fluent Samba.  Here is my procedure on how to configure the printing service in ITU:

Black and White printers:
1. Make sure you have CUPS installed.  Go to http://www.cups.org/ if in doubt.
2. Connect to your CUPS by going to http://localhost:631/
3. Administration -> AddPrinter
4. Select “Windows Printer via SAMBA” and hit “continue”.
5. Type the following in the “connection” text area:
“smb://YOURUSERNAME:YOURUSERPASSWORD@DOMAIN/printsrv/print”
Replace YOURUSERNAME with your itu user name
Replace YOURUSERPASSWORD with you itu password
DOMAIN is not replaced.
Note that there is a colon “:” in between the user name and the user password.
Hit “continue” after typing all this.
6. Choose a name I used “Black&White” and hit “continue”.  The description and location are not important.
7. Instead of choosing a printer you will provide a PDD file.  Search for the cnir23u1.ppd on your system and hit “add printer” and hit “continue”
8. And you are done.  Enjoy :) you should see the printer you just created when you try to print stuff from other apps like openoffice and epdfview.

Color Printers
Repeat the same steps as for the black and white printers.  But instead of “smb://YOURUSERNAME:YOURUSERPASSWORD@DOMAIN/printsrv/print” use “smb://YOURUSERNAME:YOURUSERPASSWORD@DOMAIN/printsrv/colourprint”.  Also make sure you use the correct PDD file.  The correct file is at cnrc322u1.ppd.gz.
If you have any issues email jogr@itu.dk.



Posted in PhD | Leave a comment

Just another way of reinstalling Fedora.

I have Fedora installed.  I’m very used to its packaging system and feel very comfortable using it.  Fedora releases every 6 months (more or less) and I like to a “fresh” reinstall every time there is a release.  I can’t say it’s a completely fresh install because I don’t install grub and I don’t change the partitioning of my hard drive.  I have a home partition, a boot partition and a swap partition that I don’t touch in the installation.  My only interest is to reinstall the operating system and the apps.

I like to install my Fedora by using the minimal boot media.  This is a small (under 300 Mbs) file that will kickstart the installation from a CD or a USB.  I prefer the USB method over the CD.  The file is in the installation trees of the various Fedora releases.  Today I installed F14, so I had to get my boot.img file from http://ftp.klid.dk/ftp/fedora/linux/releases/14/Fedora/x86_64/os/images/.

After downloading this file into my computer, I have to put it in a USB.  So I connect the USB that I will use to the port and execute the following command:

dd if=/path/to/boot.img of=/dev/sdb

Notice that the USB that I connected ended up in sdb, but this might change.

Confident of my procedure I reboot my machine and tell it to initialize from the USB key.  There you will find a menu that has various options.  I press TAB on the option that says install.  This will allow me to edit the boot line.  Given that I previously know where my installation is going to come from, I replace the stage2 option with Anaconda’s (Fedora installer) repo boot option to tell the installer where to fetch the images from.  Notice that I execute this procedure from a place with a hight speed connection.  The additional argument looks something like this:

repo=http://ftp.klid.dk/ftp/fedora/linux/releases/14/Fedora/x86_64/os

Your line will probably be different as you might not be in Denmark when you are installing.  Further notice that the line changes with architecture and Fedora release.

I press enter and the installer does its thing.  When I get to the disk partitioning part I choose “customize”.  This will take me to a window that has my disk layout.  I choose my current boot partition and press edit.  I make sure to select the label “/boot” and make sure that the format checkbox is not checked.  I continue with the root partition and select “/” label and make sure that it is checked for format.  Finally I edit my home partition, make sure that the label is “/home” and that the format checkbox is not checked.  I hit next and continue the installation. I like to customize the packages that I am installing; but if you don’t want to do that, you can just continue without customizing.

Update 10-06-2011 (Fedora 15)

Had to change a little command to my process.  After downloading the boot image from the fedoraproject site, the reboot did not work.  After some searching around I found out that the livecd-tools package provided me with the functionality I needed (put a boot image into a usb key).  Here is the command I used:

livecd-iso-to-disk /path/to/boot.img /dev/sdX

After this command my usbkey was ready to use and I could continue with the process stated above.

Posted in Uncategorized | Leave a comment

The marker thingy worked :)

After a week of debugging I got the code to do what I wanted.  I have successfully detected a bit stream in the chessboard marker image.  I had to correct for a small error that I encountered las week that was related to the hard color values that I was using.  I changed the code so that now I am using a dynamic color range.  The range is created with known colors in known positions.  With this range I can adjust to specific image characteristics.

After I killed the last bug in my code I went ahead and took pictures in different lighting setups.  The algorithm correctly detected all the colors in the marker in all the pictures.  I have to further test with outdoors lighting to see if it affects the algorithm at all.  I’ll be doing this in the coming days.

There is still a lot to do to get this to work with our Biologists collaborators:  1. There needs to be a part of the application that creates the chessboard markers;  2. There needs to be a semi-decent GUI to initialize the picture analysis process;  3. The part of the application that takes care of differentiating the images does not exist; 4. We could code stuff in a more efficient way. Though these four things are currently lacking, they are the least of my worries.  The algorithm that detects the marker works; the rest is icing on the cake.

You can get the code here.  I currently do a very crappy job at describing how to use the code.  This will also improve in the coming weeks. :)

Posted in opencv, PhD | Leave a comment

Principals of Computer System Design: Some comments (II)

While doing some more problems I noticed some more little issues that I want to get down before I forget:

  1. There is a misspell on page 282 in the before last paragraph, second line.  It says “flip-flip” when it’s supposed to be “flip-flop”.
  2. The code on page 456 (the read_input procedure) has strange indentation.  There is a while statement on line 32 that just does not make sense.  Note that this line was changed from the original implementation of read_input on page 454.   It appears that the change involved removing the “nothing” and adding a body to the while.  Unfortunately the body was added without any indentation.  IMO the body of the while in line 32 is made up of line 33 and 34.  Additionally from the strange indentation in lines 33 and 34, we have also strange indentation in lines 35 and 36.  These lines appear to be outside of the “do forever” loop.  Note that they were originally inside the “do forever” loop.  Based on the answers to problem 10 I think that these lines are also missing an indentation to the right.  In any case this part of the problem requires a review.
  3. Problem 10.10.C in page 458 asks about deadlocks in the code.  I agree with the answers given by the answer sheet, but I do not agree with the explanation.  Let me explain:  The answers states that “if the interrupt occurs between statements 35 and 36 of read_input, then the interrupt handler will set input available just before read_input resets it, and read_input will loop for ever waiting for input_available to become true.”  I don’t agree with the explanation because if the interrupt occurs between lines 35 and 36, the procedure DEVICE(n) is executed with input_available[n]=true.  And on the second line of the DEVICE(n) procedure, it would lock because the input_available[n] would never be false.  In other words it would lock in the DEVICE procedure, not in the read_input procedure.  Am I missing something?
  4. Similarly on problem 10.10.A the answer states that “If device 0 interrupts thread 0 after it checks input_available but before it gets to the statement in YIELD that changes its state to WAIT, the interrupt handler will run and call NOTIFY, then YIELD will set the thread’s state to WAIT, where it will remain forever, because it missed the NOTIFY”.  I agree that it misses the notify and there is a race condition, but I don’t agree with the word “forever”.  It will stay in this state until the next run of DEVICE(n).  Remember that DEVICE is an interrupt handler and that interrupts are only disabled inside DEVICE.  Am I missing something?

That is all I got for my second batch :)

Update 22-11-2010: My advisor made me realize that there is a deadlock for problem 10.10.A.  The deadlock occurs on a subsequent call to DEVICE.  It occurs when the thread is in wait state.  The thing to notice here is that the second call to DEVICE finds the input_available[n] variable set to true (because thread n missed the notify); this will cause the DEVICE interrupt handler to deadlock. :)

Posted in PhD | Leave a comment

Principals of Computer System Design: Some comments (I)

This semester I was TA in a class called Building Database systems, Taught by Philippe Bonnet.  The class had a strong systems design focus and the book that was used was Principles of Computer System Desing by Jerome H. Saltzer and M. Frans Kaashoek.  In general I enjoyed the book.  I think it has a unique and simple way of explaining key concepts in computer system design.  With that said, I had some issues regarding some of the problems in the book.  In general they were related with the consistency of the problem texts.  This post is a list of the ones that I can remember.  I’m not going to go very deep into the contents of the specific sections as I assume that you will buy/get the book if you are interested.

  1. Problem 2 (page 428):  Question 2.1.B asks if “the insert RPC stub on the Web server sometimes returns OK without inserting the triple into the storage system”.  Additionally the insert procedure is described as “adds the triple to the TSS if it is not already there and returns OK”.   I think that this description fails to properly distinguish two things: first, when there is no triplet in the TSS and the RPC call fails to insert one; and second, when there is a triplet in the TSS and the call to insert the same triplet does not insert it because it’s already there.  In this particular question this difference is very important because the answer changes depending on which you mean.  If you are referring to the first one, then the answer is probably that 2.1.B is not seen.  On the other hand if you are referring to the second one, then the answer is probably that 2.1.B is seen.  (2.2.B has the same inconsistency)
  2. Problem 7 (page 443):  There are some inconsistencies with the way the transfer block is handled throughout the problem.  In the beginning (page443:4th paragraph) we are presented transfer as a block of memory and both the client and the service map to that address block.  In the description of init_service we are again told that transfer is a block since it is called with the allocate_block function (Page 248 refers to allocate_block as returning the physical address of the block).  The problem description continues to say “… copies the LRPC into the transfer page. …”; This passage hints that transfer is not a block and in fact is a page that needs to be translated into a block (page:246 numeral 1,2).  On the same paragraph it continues to say “… writes the result parameters in the transfer block and transfers…”; this adds to the inconsistency referring to transfer as a block again.  Finally en the 7.2 question on page 445 it asks “For the LRPC to work correctly, must the two virtual address transfer have the same value….”; this again refers to transfer as a virtual address adding to the inconsistency.  My intuition here is that transfer is a block and should be referred to as a block through out all the problem 7.7.
  3. The answer to 7.7.A (page 446) requires making assumptions about receive, but the problem states that “(the code for the procedure at the address receive is not shown because it is not important for the questions)”, which hints at the answer being in another place.  The question is inconsistent in telling you that you shouldn’t look for answers in receive, when in fact one of the answers is there.  Notice that this also happens with 7.7.{B,C,D} but to a lesser degree.
  4. The answer to 7.7.A (page 446) requires assuming that receive copies whatever is in transfer to its private address space.  But in the problem there is no place where this assumption is hinted at.  Note that Return_LRPC copying the return statement from receive from transfer says absolutely nothing about how transfer is implemented.

These 4 are the ones that I have fresh in my memory :)

Posted in PhD | Leave a comment

New project image label

After some weeks of fiddling with opencv chessboard functions, I finally managed to detect some information on a modified board.  I do still need to address some small mistakes that are related to color detection.  These should be ironed out in the next couple of weeks.  For further detail on what the project is targeting and how the project is developed please go to the github repository and read the project description.

My next move regarding detection accuracy is to create a dynamic color range histogram.  This will entail having 6 known squares with the colors that I want to detect and from these, calculate some simple statistical values (mean, median, quartile).  Finally, with the calculated statistical information, I can create color ranges that will then define the detection algorithm.  I hope that this will be enough to get rid of some errors I have seen in the resulting bits.

Posted in opencv, PhD | Leave a comment

Useful (To me :) Vim commands.

It’s been a while since I have changed my vimrc file.  I recently had to do it to activate “textwidth” in my home box.  I still do not understand why it was not set to the usual 80 characters that I like.  It probably has been like that for some years but I never notice because I don’t do a lot of coding in that machine.  In any case, that pushed me to create a post about the commands that I have used over the years that I think are worth noting :).  Instead of listing the vim commands and what they do, I’m going to list what I needed to do and how I did it.  The meaning of the commands you can always find with vim help.

Different tab schemes for different filetypes

I try to follow the GNU coding style when I code in C or in C++.  This means, among other things. 2 space tabs.  On the other hand, I like to write my python code with 4 space tabs.  To accomplish this I use “autocmd” along with “execute” and “set”.  autocmd adds a predefined command that gets executed along with other autocmd commands.  In short, I have a line that detects the type of file I am editing and sets the vim tab parameters; all this in one line :).  Here is an example:

autocmd FileType c execute "set tabstop=2 shiftwidth=2 softtabstop=2"

The third word in the command is the type of file.  Vim understands strings like “python”, “javascript”, “html” and so on.  Notice that I tell vim to execute a multiple set.  It is necessary to enclose the command in quotation marks.

My lines should be of certain length

I have always been comfortable with a line length of 80 chars.  I’ve heard people argue that 72 is better.  I used to use 72 when I used mutt.  But I use 80 because it allows me to place two windows with code, side-by-side, and completely visualize the code (There is no code lost to the end of the window and/or there is no code that is wrapping around where it’s not supposed to).  Also, visualizing and comparing two diffs is much easier (I don’t do this much).  In any case the vim command to do this is “textwidth”.  Here is an example:

set textwidth=80

Painless spell checking.

This bit of code is not of my doing.  I downloaded my initial vimrc from… I don’t remember where and it already had the spell checking function in there.  I have looked at it a couple of times and I think its worth mentioning.  If you add this to your vimrc you will be able to toggle spell check with the F11 key.  It comes in handy when writing documents.

function s:spell()
if !exists("s:spell_check") || s:spell_check == 0
echo "Spell check on"
let s:spell_check = 1
setlocal spell spelllang=en_us
else
echo "Spell check off"
let s:spell_check = 0
setlocal spell spelllang=
endif
endfunction
map <F11> :call <SID>spell()<CR>
imap :call spell()

I’ll leave this post with those 3 little tips. :)

Posted in Uncategorized | Leave a comment

New Annotation feature

After discussing the current state of the annotation software, I realized that it needed a  bit of attention.  One of the issues that we discussed, and the one that stayed in my head, was the strangeness when editing the annotations.  The issues stemmed from having to delete and recreate each annotation which needed a label change; when the most logical thing would be to just change the label (without recreating).

I tinkered a bit with the code and got it to a point where the selected annotation will change label when the label is selected from the label list.  This turns a three-step process into a 2 step process.  Though this might not seem like much, imagine that we have to annotate hundreds of images, each with about 20 annotations each.  I think that this  increases the annotation productivity considerably :)

You can see the commit that adds the feature here.

Posted in annotation, PhD | Leave a comment