Wednesday Feb 10, 2010

Fast Track to OpenSolaris minibook - Now available for download

EDIT: If you are having troubles downloading the PDF of the book from Scribd, you can download it from my personal server (follow this link).

Last month was pretty happening. I, in capacity of being leader for Mumbai OpenSolaris User Group (http://hub.opensolaris.org/bin/view/User+Group+mmosug/), spent last month working with the editorial team of Digit Magazine (http://www.thinkdigit.com) to come up with a minibook on OpenSolaris. Even though we got a very little time to finish a massive project like this, but with help of everyone, finally we could finish it in time and on the first day of this month (1/FEB/2010) 100,000 copies of the book- "Fast Track to OpenSolaris", along with a OpenSolaris CD with each copy, hit the newsstands all across the country! It took me 10 days to finish the book and it was the first time that I found myself writing a book of any sort.

Now Fast Track to OpenSolaris is available for download: http://www.scribd.com/doc/26659478/Fast-Track-to-OpenSolaris

Fast Track to OpenSolaris

Digit and Mumbai OSUG are jointly running a online Quiz competition (OpenSolaris Geek Hunt) at http://www.thinkdigit.com/opensolaris  Participate in this quiz to test your OpenSolaris skills and even win a Acer Aspire One Netbook, 1 TB or 500 GB external hard disk and many more OpenSolaris goodies!

OpenSolaris Geek Hunt


I hope you all like the quiz and enjoy the book. Please feel free to drop me a line if you find any errors in the book. Also, please note that I wrote this book as a OpenSolaris community member and not as a Sun Microsystems Inc employee. So all the views and opinion and facts mentioned in this book are essentially mine and Sun should not be held responsible for mistakes and errors, if any! Now go ahead and geek out with OpenSolaris!

Sunday Dec 20, 2009

What happens under the hood when you execute your C Programs?

I was a little curious to find out how my program gets executed. In order to find that out, I decided to write a simple c program which is here:



 #include <stdio.h>
int main()
{
    sleep(30);
    printf("Just testing an application!");
}



I have kept the sleep(30) in the beginning of the program so as to give me time to execute the DTrace script, about which I will be talking a little later.


Now i complied it with Sun Compiler and GCC



kumar@myosbox:~/Desktop/Demos$ suncc -o sunCCOutput simplec.c


kumar@myosbox:~/Desktop/Demos$ gcc -o gccOutput simplec.c



Now I wrote a simple DTrace script using the pid provider in order to figure out how printf is implemented (execution detail - functions which get invoked when printf function is called) in these compilers. The dtrace script is below:



pid$1::$2:entry
{
        self->trace = 1;
}

pid$1::$2:return
/self->trace/
{
        self->trace = 0;
}

pid$1:::entry,
pid$1:::return
/self->trace/
{
}



Now it was the time to execute this script and compare the outputs. I am going to redirect the output of this script into two text files (sunCCOutput.txt and gccOutput.txt).



kumar@myosbox:~/Desktop/Demos$ ./sunCCOutput 
kumar@myosbox:~/Desktop/Demos$ pfexec dtrace -F -s pid.d `pgrep sunCCOutput` printf > SunCCOutput.txt
dtrace: script 'pid.d' matched 6712 probes
kumar@myosbox:~/Desktop/Demos$ ./gccOutput
kumar@myosbox:~/Desktop/Demos$ pfexec dtrace -F -s pid.d `pgrep gccOutput` printf > gccOutput.txt
dtrace: script 'pid.d' matched 6714 probes



Now, the content of the file SunCCOutput.txt is as follows:



CPU FUNCTION                                 
1 -> printf
1 -> _setorientation
1 <- _setorientation
1 -> _ndoprnt
1 -> _findbuf
1 -> isatty
1 -> ___errno
1 <- ___errno
1 -> ioctl
1 <- ioctl
1 <- isatty
1 -> _setbufend
1 -> getxfdat
1 <- getxfdat
1 -> isseekable
1 -> ___errno
1 <- ___errno
1 -> fstat64
1 <- fstat64
1 -> ___errno
1 <- ___errno
1 <- isseekable
1 <- _setbufend
1 <- _findbuf
1 -> _realbufend
1 -> getxfdat
1 <- getxfdat
1 <- _realbufend
1 -> memcpy
1 <- memmove
1 <- memcpy
1 -> memchr
1 <- memchr
1 -> ferror
1 <- ferror
1 <- _ndoprnt
1 -> ferror
1 <- ferror


Contents of the file gccOutput.txt is as follows:



CPU FUNCTION                                 
1 -> printf
1 -> _setorientation
1 <- _setorientation
1 -> _ndoprnt
1 -> _findbuf
1 -> isatty
1 -> ___errno
1 <- ___errno
1 -> ioctl
1 <- ioctl
1 <- isatty
1 -> _setbufend
1 -> getxfdat
1 <- getxfdat
1 -> isseekable
1 -> ___errno
1 <- ___errno
1 -> fstat64
1 <- fstat64
1 -> ___errno
1 <- ___errno
1 <- isseekable
1 <- _setbufend
1 <- _findbuf
1 -> _realbufend
1 -> getxfdat
1 <- getxfdat
1 <- _realbufend
1 -> memcpy
1 <- memmove
1 <- memcpy
1 -> memchr
1 <- memchr
1 -> ferror
1 <- ferror
1 <- _ndoprnt
1 -> ferror
1 <- ferror

So you can see that there is no difference between gcc and suncc when if comes to implement the printf function. But its is so interesting to see that there are 19 function calls made everytime I use a printf in my c program! WOW! ;) I wonder if I could know it this easily if there was no Dtrace!

Friday Dec 11, 2009

Create a ZFS Storage pool on a Pen drive / USB Stick in OpenSolaris

You can do some crazy stuff with OpenSolaris and ZFS! Here is my crazy deal. Lets create a ZFS storage pool such that we have 2 Pen drives of 2 GB each and lets use it to save on big file of 3.5 GB (read store a nice DVD quality movie on two 2GB pendrives :P )


You will need two things for this:


1. Install OpenSolaris


2. Get two or more 2 GB (or of whatever size) pen drives / USB sticks (I do not have  2 pen drives with me so I will use one pen drive and one file to act like a pen drive. Process remains the same)


Step 1: Find out the device ID of your pen drive:



root@opensolaris:~# format -e
Searching for disks...done


AVAILABLE DISK SELECTIONS:
       0. c7d0 <DEFAULT cyl 3271 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c9t0d0 <Generic-Flash Disk-8.07-1.87GB>
          /pci@0,0/pci8086,265c@b/storage@1/disk@0,0
Specify disk (enter its number):



In this case, the disk 0 is my hard disk, and 1 with device ID c9t0d0 is the USB stick. If I had two pen drives I would have had one more entry. However, I am going to create a new file of 2 GB under the name disk1 and use it.


Step 2: Create a new zpool on these devices. If you are using many multiple pen drives then instead of /root/disk2 use the device ID of the devices.



root@opensolaris:~# zpool create randomZpool c9t0d0 /root/disk2
root@opensolaris:~# zpool status -v
  pool: randomZpool
 state: ONLINE
 scrub: none requested
config:

    NAME           STATE     READ WRITE CKSUM
    randomZpool    ONLINE       0     0     0
      c9t0d0       ONLINE       0     0     0
      /root/disk2  ONLINE       0     0     0

errors: No known data errors

  pool: rpool
 state: ONLINE
 scrub: none requested
config:

    NAME        STATE     READ WRITE CKSUM
    rpool       ONLINE       0     0     0
      c7d0s0    ONLINE       0     0     0

errors: No known data errors



 Step 3: Create a ZFS filesystem on the storage pool



root@opensolaris:~# zfs list | grep randomZpool
randomZpool               101K  3.77G    19K  /randomZpool
randomZpool/dummy          19K  3.77G    19K  /randomZpool/dummy



Now you can see, that I have a ZFS filesystem of 3.77GB under the name randomZpool/dummy. Now let us define a mount point for the same.


Step 4: Define a mountpoint for the ZFS Filesystem.


root@opensolaris:~# zfs set mountpoint=/export/movies randomZpool/dummy
root@opensolaris:~# df -h /export/movies
Filesystem            Size  Used Avail Use% Mounted on
randomZpool/dummy     3.8G   19K  3.8G   1% /export/movies

 Now you have the backup of your 3.5 GB movie file on two pen drives :)


How you can use this small arrangement to do much bigger (and crazier) stuff is limited only by your creativity ;)


Happy hacking to all!



Tuesday Feb 24, 2009

And We are back again! With Education, Open Source, Tech Days and Joe!

Hello!! Its been more than 6 months since I made my last blog entry... Sorry for that as I was busy working with loads of stuff in Sun Clusters, OpenSolaris Marketing and in Campus Ambassador Program.. But now I am back with some interesting stuff...


Sun Tech Days happened at Hyderabad from 18th Feb to 20th Feb which was attended by many many people! Many legends including James Gosling were there for the show! Joe Hartley was there for the event on 20th Feb and I took this opportunity to catch up with him about developments on education, open source and technologies to look for! Joe gave us some insights on what the future of education might be in light of growing adoption of social networking services like OSUM and penetration of the network. With help from Vasudha who is our campus ambassador at Manipal University, we recorded this pool side talk :-) Here is the video:



It was very interesting to talk to Joe after an year of WWERC 2008 held at San Francisco where I got a chance to interview him on similar lines. Watch that video here!

Tuesday Jul 01, 2008

OHAC talk at GLOSS

After almost a month long vacation, when college reopened, we at GLOSS could not wait to do something exciting!! And what could be more exciting than Open High Availability Clusters (OHAC). I attended a talk on OHAC by Tirthankar during my recent visit of Sun India Engineering Center at Bangalore. I was completely taken by the technology and I knew I am going to do something with it, the moment I get a chance. Anyways... the day I landed in college, I sat down to set up a one node cluster on my laptop! Million thanks to Tirthankar again, who spend almost whole of his Sunday with me over the phone helping me out in setting it up. I would be blogging how set up a one node cluster on Solaris SXDE some time very very soon.


Now about the talk! There was a decent audience of more than 40 students who came to attend the talk. I started the talk with playing the Big Bucks Bunny movie, which set up the mood of the audience and also allowed me to introduce them to Network.Com and from there pick up the topic of difference between grids and clusters.



 Then I moved to the slides and I explained the architecture of OHAC and details of its functioning. It was an engrossing session, as explaining the functioning of a cluster and concepts like Disk Fencing can get tricky :) But it was nice to see every one interacting and asking questions to me!




Then was the turn of the Demo.. something which I was very eager to show. For this demo, I had prepared a single node cluster on my laptop. I had a zone running on which we had a cluster resource name movie-rg registered. The cluster agent was basically written to start RealPlayer on cluster and in case of a failure, it would make it failover to a functioning node of the cluster. The experience of setting up the cluster and getting the agent to work was truely amazing! As I said, I would be blogging about it soon, so check back soon. Here are two screenshots which shows how cluster took care of availability


Cluster resource right now online on the zone


 Now when I reboot the zone, the cluster resource becomes online on the physical node



I will soon be doing one more follow up talk on OHAC where I would discuss how to setup clusters and write agents for OHAC! Once again... thanks to Tirthankar and Swathi for helping me out with OHAC!

Monday Jun 09, 2008

5 OpenSource Goodies to get you going!

There can be many a times when you cannot afford to spend those valuable $$$ to prove your concept or express yourself or give you the start you are looking for ;) Then where do you go?? Now that open source has become such a big thing, that I don't think I need to explicitly answer this question!! But then, identifying what application to use and where can get a bit daunting (As daunting as atleast 3 rounds of googling :-P)!! Anyways, here I would like to recommend 5 open source application which can get you rolling with your concept.... Note that, each of these projects are mature enough that they can be used for every mission critical operations and you can trust them to run your whole business.





    • Netbeans is what you should be asking for if you are looking at creating any Rich Client Application quickly! Be it Database driven applications or a stand alone tiny application, Netbeans is the best choice for you! Anytime you wish to exploit the power of Java Technology then Netbeans is your man ;) Not to forget, if you are planning to create a  nifty mobile application which you can use to adore your cell phone then look nowhere else. Many other things like Ruby, C and C++ etc. runs smoothly!




    • Productivity suites can be really expensive. But OpenOffice.org is an amazing Office application which is very feature packed and complete. And the best thing is that it comes sans price tag! Direct PDF convertion, native support to the ODF and MS Office formats and hundreds of other features very much make OpenOffice.org a-must application!




    • Sun xVM (VirtualBox) would allow you to run anything on anything! Run OpenSolaris on Windows, Windows on OpenSolaris, Windows on Linux and Linux on Windows and many such other combinations! VirtualBox OSE would allow you to test your applications on whatever platform you want. With a download less than 25 MB, you are ready to go to install any platform in your system without actually needing to buy any separate hardware for each platform.




    • Now that you have a IDE and Office plus a virtualization application in place, you would need something to run your Website. Drupal is a right choice if you are looking for a contect driven website. Written using PHP and supports both MySQL and PostgreSQL, Drupal can me made as feature rich as possible, using thousands of community contributed module!




    • XAMPP would allow you to install the comple Apache, MySQL and PHP part of the xAMPP platform. Its a simple to use and easy to download!



The beauty of all these applications are that they run on almost all popular platforms! You are free to use which ever operating system you want to run these applications. They help you get off the ground easily. Infact, if you are smart enough, you would take the extra effort to get yourself a copy of OpenSolaris, which would cost you nothing and provide you a reliable, feature full and stable development environment. And if you are considering to do a next facebook or something then check out OpenSolaris Web Stack which would give you a SAMP platform on a platter! :)


 These are some of the applications I like a lot in the OpenSource ecosystem. There are million others and almost any of your needs can be fulfilled in the OpenSource world!


Now tell me, doesn't open source deserve the title of biggest enabler of our century??? :)


Technorati Profile

Thursday May 29, 2008

Firefox Download Day!

Firefox has redefined the way we browse the web isn't it! Now if anything deserves a  world record then firefox is ofcourse one of the top ones in the list. With Firefox 3 being released in the near future, Firefox this time is getting ready to set a world record for maximum number of software downloads in 24 hours!

To keep us reminded, Firefox community has setup a pledge and reminder service. You can go and take a pleadge to download Firefox 3 and help Firefox community to set this world record by visiting the Download Day Homepage!

So lets go and download Firefox 3 and set up a world record!! :-)

Now let me tell you what we did last summer :-)

I got a secret to share :-P When everyone around the globe was impatiently waiting for OpenSolaris 2008.05 to release, on April 13, 2008, we at GLOSS got lucky!! Thanks to Micheline and Charlie, I could obtain a copy of OpenSolaris Release Candidate 0!!! Yes! we were one of the first one's to see OpenSolaris 2008.05 (exactly the way you see a baby through the ultrasound :-D) and we got our hands on RC0 before any other group outside Sun :-) And then how could we wait to find out how the new desto has come out!! We did and we did it with lots of passion and zeal. 200 students tried their hands on OpenSolaris RC0, and even though RC0 only had the skeleton, (like there were no images during installation, but only the ImagePlaceHolder label was there!) everyone was deeply impressed with the ease with which they could install the distro. We collected the feedbacks towards the end of the test drive and by running through the feedback forms I we knew what the everyday user of OpenSolaris 2008.05 would like and what more they would expect! Angad did a similar thing at his campus in a very innovative way! His blog about this virtual install fest of RC0 is a must-see.


As I told you, it was a matter of pride for us to see and test OpenSolaris RC0 and everyone was overjoyed after we were done. Here is one clip which one of us shot..




I guess it will give you an idea of how passionate we, at GLOSS, feel about OpenSolaris! :-)



Technorati Profile

About

I am Abhishek and I work for Sun/Oracle! In this blog, I share my interest in systems, solaris, linux and other technologies :-)

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today