2009年10月16日 星期五

Ubuntu - To skip hard drive check that caused System to not boot up

When booting up,
The following is observed again and again, endlessly.....There is potentially something wrong with the hard drive blocks. (bad-blocks maybe)

ata2.00: atatus: {DRDY}
ata2: soft resetting link
ata2.00: configured for UDMA/33
ata2:EH Complete

There is a work-around to skip the hard drive check so that the system will boot up

sudo gedit /boot/grub/menu.lst

Appending the following to the kernel boot options:

irqpoll noprobe=ata2

Resolution Issue - Ubuntu boot-up/shut-down without startup/shutdown splash screen

There is a simple 3 step process to solve this problem-

1. Type ’sudo gedit /etc/usplash.conf’

# Usplash configuration file
xres=1280
yres=1024

You have to change 1280 to 1024 in the x resolution and 1024 to 768 in the y resolution

2. Step 1 should solve the shut-down problem.To solve the start-up problem,you need to follow step2 and step3. Now edit /boot/grub/menu.lst by typing ’sudo gedit /boot/grub/menu.lst’. In this file reach the line

## ## End Default Options ##

By default the next paragraph will have the boot information for the option you choose while booting up.It will say something like-

title Ubuntu 7.10, kernel 2.6.22-14-generic
root (hd0,9)
kernel /boot/vmlinuz-2.6.22-14-generic root=UUID=ebddbc03-0e71-41dd-babd-278109f26a95 ro quiet splash
initrd /boot/initrd.img-2.6.22-14-generic
quiet

At the end of the line next to kernel,next to splash add ‘vga=791′.791 is the code for 1024X768 resolution in 16 Bits.What this does is that it changes the screen resolution of all following steps but not of the xserver.You can select any other resolution which your monitor is comfortable with.
Here are some typical values for some screen resolutions-

Colours   640x400 640x480 800x600 1024x768 1152x864 1280x1024 1600x1200
--------+--------------------------------------------------------------
4 bits | ? ? 770 ? ? ? ?
8 bits | 768 769 771 773 353 775 796
15 bits | ? 784 787 790 354 793 797
16 bits | ? 758 788 791 355 794 798
24 bits | ? 786 789 792 ? 795 799
32 bits | ? ? ? ? 356 ?


3. The third step is a copy and paste step.In this step,you need to execute a command to update the settings and generate a new usplash image of the resolution you selected. Execute this command in a terminal window-

sudo update-initramfs -u -k `uname -r`

Reboot your computer now and I’m sure you’ll be able to see the orange Startup splash screen without any trouble now.

Overhead (Computer Science)

The processing time required by a device prior to the execution of a command

2009年3月20日 星期五

The explicit Keyword in C++

A constructor declared with only one argument and without the explicit keyword is a converting constructor. You can construct objects with a converting constructor using the assignment operator. Declaring a constructor of this type with the explicit keyword prevents this behavior. The explicit keyword controls unwanted implicit type conversions. It can only be used in declarations of constructors within a class declaration

For example, if you declare the class as:

class A
{ public:
explicit A();
explicit A(int);
explicit A(const char*, int = 0);
};

You can only assign values that match the values of the class type.

For example, the following statements will be legal:

A a1;
A a2 = A(1);
A a3(1);
A a4 = A("Venditti");
A* p = new A(1);
A a5 = (A)1;
A a6 = static_cast<A>(1);
And the following is illegal since the constructor is explicit

A a7 = 7;

What is a Conversion Constructor

A Conversion constructor is a single-parameter constructor that is declared without the function specifier explicit. The compiler uses converting constructors to convert objects from the type of the first parameter to the type of the converting constructor's class. The following example demonstrates this:

class Y {
int a, b;
char* name;
public:
Y(int i) { };
Y(const char* n, int j = 0) { };
};

void add(Y) { };

int main() {

// equivalent to
// obj1 = Y(2)
Y obj1 = 2;

// equivalent to
// obj2 = Y("somestring",0)
Y obj2 = "somestring";

// equivalent to
// obj1 = Y(10)
obj1 = 10;

// equivalent to
// add(Y(5))
add(5);
}

The above example has the following two converting constructors:

  • Y(int i)which is used to convert integers to objects of class Y.
  • Y(const char* n, int j = 0) which is used to convert pointers to strings to objects of class Y
A copy constructor is a converting constructor.

What is auto pointer?

The simplest example of a smart pointer is auto_ptr, which is included in the standard C++ library. Auto Pointer only takes care of Memory leak and does nothing about dangling pointers issue. Auto_ptr is a simple wrapper around a regular pointer. It forwards all meaningful operations to this pointer (dereferencing and indirection). Its smartness in the destructor: the destructor takes care of deleting the pointer.

For the user of auto_ptr, this means that instead of writing:

void foo()
{
MyClass* p(new MyClass);
p->DoSomething();
delete p;
}

You can write:

void foo()
{
auto_ptr p(new MyClass);
p->DoSomething();
}
And trust p to cleanup after itself

If you use auto_ptr objects you would not have to be concerned with heap objects not being deleted even if the exception is thrown.

What is Memory Leak?

Memory which has no pointer pointing to it and there is no way to delete or reuse this memory(object), it causes Memory leak.

{
Base *b = new base();
}

Out of this scope b no longer exists, but the memory it was pointing to was not deleted. Pointer b
itself was destroyed when it went out of scope.

What is a dangling pointer?

A Dangling Pointer arises when you use the address of an object after its lifetime is over. This may occur in situations like returning addresses of the automatic variables from a function or using the address of the memory block after it is freed
{
char *cp = NULL;
/* ... */
{
char c;
cp = &c;
} /* c falls out of scope */
/* cp is now a dangling pointer */
}

To resolve dangling pointer issue:

#include
{
char *cp = malloc ( A_CONST );
/* ... */
free ( cp ); /* cp now becomes a dangling pointer */
cp = NULL; /* cp is no longer dangling */
/* ... */
}

2009年3月18日 星期三

Software architecture

The software architecture of a program or computing system is the structure or structures of the system, which comprise software components, the externally visible properties of those components, and the relationships between them. The term also refers to documentation of a system's software architecture. Documenting software architecture facilitates communication between stakeholders, documents early decisions about high-level design, and allows reuse of design components and patterns between projects

Teamwork

Collaboration requires effective team work. Team members must trust and respect one another. There must be open communication and a willingness to accept input from others.

There are often conflicting goals in product development. Therefore decision-making must be based on a collaborative approach. This is shown with the following model.

Collaboration

Collaboration is the basis for bringing together the knowledge, experience and skills of multiple team members to contribute to the development of a new product more effectively than individual team members performing their narrow tasks in support of product development. As such collaboration is the basis for concepts such as concurrent engineering or integrated product development

Effective collaboration requires actions on multiple fronts:

  • Early involvement and the availability of resources to effectively collaborate
  • A culture that encourages teamwork, cooperation and collaboration
  • Effective teamwork and team member cooperation
  • Defined team member responsibilities based on collaboration
  • A defined product development process based on early sharing of informatin and collaboratin
  • Collocation or virtual collocation
  • Collaboration technology

2009年3月17日 星期二

Thoughts After Interview with VTech

- Do not put anything you are not able to explain in details on resume
- Architecture Pattern/Design on each project
- Design Decision
- Implementation Design/Details
- Able to talk about any project on a whiteboard

The Downside of MultiThreading

One downside is that thread switching consumes resources. Each time the CPU switches from one thread to another, the state of the current thread must be saved, so it can be resumed later, and the state of the new thread must be retrieved and loaded into the CPU registers. Just adding one extra thread to improve responsiveness is not going to cause any noticeable problems, but if you use, say, 20 threads in a complex statistical analysis program, the extra overhead of task switching may nullify the theoretical advantages of multithreading.

The second downside is that programming multiple threads can be complex. One problem that faces programmers is called a deadlock, when two threads are each waiting for the other to complete, resulting in neither thread ever completing. A related problem, called a race, results when the program's operation depends on which of two or more threads completes first. While .Net provides classes and tools to deal with these and other problems of thread management and synchronization, it remains a complex business.

http://www.informit.com/articles/article.aspx?p=170919&seqNum=2