Friday, October 28, 2011

Duff's Device.. Worth A Thought...Power of C..




register n = (count + 7) / 8;      /* count > 0 assumed */

   switch (count % 8)
   {
   case 0:        do {  *to = *from++;
   case 7:              *to = *from++;
   case 6:              *to = *from++;
   case 5:              *to = *from++;
   case 4:              *to = *from++;
   case 3:              *to = *from++;
   case 2:              *to = *from++;
   case 1:              *to = *from++;
                      } while (--n > 0);
   }


What it does is exactly same as:

send(to, from, count)
 register short *to, *from;
 register count;
 {
  do
   *to = *from++;
  while(--count>0);
 }

Dont worry about '*to' same pointer. it was originally coded for serial copying to one output port.

Details: http://drdobbs.com/web-development/184406208


Monday, October 17, 2011

Daily job.. few commands/things to jot down

1. To logout a user using terminal:
>skill -KILL -u

2. If stuck with the error while logging in.. as " An error occurred while loading or saving configuration information for gnome-session. Some of your configuration settings may not work properly"


do  in home directory :  "rm -rf .gnome .gnome2 .gconf .gconfd .metacity"

Monday, April 11, 2011

And A Link from LifeHacker .. Installing a Hackintosh

http://lifehacker.com/#!5672051/how-to-build-a-hackintosh-mac-and-install-os-x-in-eight-easy-steps
http://tonymacx86.blogspot.com/2010/04/iboot-multibeast-install-mac-os-x-on.html

Hope to come back one day to try this out..

---------

Friday, April 8, 2011

a bit on thread id


how to get a thread's ID in c/c++ gnu, gettid() is not implemented

pid_t gettid(void);

can be replaced by the following system call :

#include < syscall.h >
pid_t tid = (pid_t) syscall (SYS_gettid);

Thread ids obtained from pthread_self() are in a different format..
...