Wednesday 16 July 2014

Is hacking always bad?

Initially, Hacking was used to describe an activity done as a hobby, usually in a sophisticated manner. It basically had no relations with doing anything with computers (Harvey, n.d.), and only after the discovery of computers, the term “Computer Hacking” came into use. In actual sense, computer hacking meant doing anything using the computer as a pastime, which included making computers do almost anything that they are normally not made for.

However, at present, people generally refer to computer hacking as a criminal offence that consists of activities like breaking into computer systems, stealing people’s or organizations’ data, and doing some sort of damage, using computers or computer-like devices. Quite easily, the list can go on. Historically, many illegal activities done using computers have been recorded as the acts of hacking. Hacking has mostly been perceived as doing illicit things with computers though the hackers (and their communities) have disagreed with all of it and labeled such people with unethical intents as “crackers” and/or “phreaks” (BBC News, 2000).

The Dining Philosophers Problem

A Solution: Breaking the Dependency” improves upon the Broken Solution”.

The Dining Philosophers problem is a classic concurrency or synchronization problem in Operating Systems. E. Dijkstra posed and solved this problem in 1965. In this problem, there are 5 philosophers around a dining table and 5 forks available for eating. The life of the philosophers consists of alternative period of eating and thinking, and eating needs two forks (left and right). When philosopher gets hungry, he/she tries to acquire two forks, eats for a while, and then puts down the forks and continues to think.


The broken solution is that when the philosopher is hungry, he/she picks up the left fork first and waits for right fork, when gets it eats for a while and put both forks back to the table (Arpaci-Dusseau & Arpaci-Dusseau, 2014). The problem with this solution, because of which it is called “broken”, is that if all philosophers pick up the forks to their left and wait for the ones on the right, nobody will get to eat (as all forks are already acquired) leading to a deadlock. This phenomenon can be said to be “Circular Wait”.

The solution “Breaking the Dependency” improves upon it by changing the way the forks are acquired by one philosopher. More specifically, Philosopher 4 (or any other philosopher) can be made to pick up the right fork first, instead of the one on the left (Arpaci-Dusseau & Arpaci-Dusseau, 2014).  
void getforks() {
if (p == 4) {
sem_wait(forks[right(p)]);
sem_wait(forks[left(p)]);
} else {
sem_wait(forks[left(p)]);
sem_wait(forks[right(p)]);
}
}