Print Email Download Reference This Send to Kindle Reddit This
submit to reddit

A Process Is A Program In Execution Information Technology Essay

Objects can interact with each other by using message passing. Each object consists of both data and operations or methods on that data. They are also can come from the same class. The difference between them is only the data. In the object-oriented paradigm, at most one machine can be executing at a time. With the existence of the concept of concurrency, these objects can be executing simultaneously.

A good example of a concurrent program is the modern web browser. Once we open a page, there are a lot of objects are executing at the same time, for example, images, text, links, etc.

CONCEPTS

A process is a program in execution.

Each process has its own state. It is not dependent on other process or program.

A process also has attached resources, such as files, memory, and so on.

A concurrent program is a program that has two or more execution environments runs at the same time. Such a program is said to be multithreaded, since it has more than one execution environment.

A parallel program is a concurrent program in which more than one execution context or thread is active simultaneously. Both definitions sound has same meaning, but in computer science concurrent happens to properties of a program that has non predetermined tasks.

A distributed program consists of several programs run for the same purpose communicating through network. However, every single program has own processor and does not share memory.

On the other hand, multiprocessing operating system is when one program is executed by multiple processes. Every process has its own result.

A thread has 5 states as illustrated below:

Created: the thread has been created, but it is not yet ready to run

Runnable or ready: the thread is ready to run, but awaits getting a processor to run on.

Running: the thread is actually executing on a processor

Blocked or waiting: the thread is either waiting on gaining access to a critical section or has voluntarily given up the processor

Terminated: the thread has been stopped and will not execute again.

created

blocked

runnable

running

terminated

Figure: states of thread

Assignments

Watch and summarize this video content http://www.youtube.com/watch?v=1UrRVYLnbjU&feature=related

In your opinion, why system analysts seldom use concurrent engineering method in software development?

What is the first programming language has concurrent feature?

Answer: PL/I

Communication

The reasons of communication in thread:

Threads compete for exclusive access to shared resources, e.g., files

To exchange data

Threads communicate through:

Nonlocal shared variables

Message passing

Parameters

Race Condition

The race condition is the fundamental problem in sharing access.

How?

When the function executed depends on order of execution. For example, for the statement

c = c + 1 ;

The sequence of instructions executed in a single machine may look like:

load c

add 1

store c

Assume that each of the above instructions is atomic; that is each instruction runs to completion without being stopped or interrupted. However, a thread can be stopped between any two instructions.

If the initial value c is 0, then depending on the order of instructions executed by the two threads, either of the final values 1 or 2 is possible. Imagine the following sequence of events: thread A executes instructions 1 and 2 next thread B executes 1 and 2; then thread A executes instructions 3; and finally thread B executes instructions 3:

Thread A

Thread B

Next

Next

C

Executing

Instr

Register

Instr

Register

Memory

Initial

1

?

1

?

0

A

2

0

1

?

0

A

3

1

1

?

0

B

3

1

2

0

0

B

3

1

3

1

0

A

4

1

3

1

1

B

4

1

4

1

1

Quiz

What is race condition?

Answer: A race condition is an undesirable situation that occurs when a device or system attempts to perform two or more operations at the same time, but because of the nature of the device or system, the operations must be done in the proper sequence in order to be done correctly (whatis.com).

Deadlock

A deadlock is a situation where in two or more competing actions is each waiting for the other to finish, and thus neither ever does. It is often seen in a paradox like the "chicken or the egg" (Wikipedia.com).

A state of deadlock is when a thread is waiting for an event that will never take place.

Conditions of deadlock:

Threads must claim exclusive rights to resources

Threads must hold some resources while waiting for others

Resources may not be removed from waiting thread

A circular of tread exists in which each thread holds one or more resources required by the next thread in the chain.

One of the techniques to avoid deadlock is called Banker’s Algorithm.

Quiz

What is deadlock?

Answer: A deadlock is a situation where in two or more competing actions is each waiting for the other to finish, and thus neither ever does.

Semaphore

Semaphore consists of an integer variable and an associated thread queuing mechanism. Two atomic operations are defined on semaphores, P and V:

P(s) : if s>0 then s=s-1 else the thread that called P is blocked

V(s) : if a thread T is blocked on the same semaphore s, then wake up T, else set s=s+1

If the value of the semaphore only takes on the values 0 and 1, the semaphore is a binary semaphore. A semaphore that can take on arbitrary nonnegative values is termed a counting semaphore.

Quiz

What is the purpose of semaphore?

Answer: it is used to protect or control program access by multiple processors.

Test

Define and explain concurrent program.

Answer

A concurrent program is a program that has two or more execution environments runs at the same time. Such a program is said to be multithreaded, since it has more than one execution environment.

A parallel program is a concurrent program in which more than one execution context or thread is active simultaneously. Both definitions sound has same meaning, but in computer science concurrent happens to properties of a program that has non predetermined tasks.

A distributed program consists of several programs run for the same purpose communicating through network. However, every single program has own processor and does not share memory.

On the other hand, multiprocessing operating system is when one program is executed by multiple processes. Every process has its own result.

A thread has 5 states as illustrated below:

Created: the thread has been created, but it is not yet ready to run

Runnable or ready: the thread is ready to run, but awaits getting a processor to run on.

Running: the thread is actually executing on a processor

Blocked or waiting: the thread is either waiting on gaining access to a critical section or has voluntarily given up the processor

Terminated: the thread has been stopped and will not execute again.

created

blocked

runnable

running

terminated

Figure: states of thread

Why communication happens in thread?

Answer

Threads compete for exclusive access to shared resources, e.g., files

To exchange data

When is multithread used in software development?

Answer

It is used to increase the performance of executing a program that involves more than one processor or/and hardware.

How deadlock happens?

Answer

Deadlock is a situation that occurs when two or more users are waiting for data locked by each other. Oracle automatically detects a deadlock and resolves them by rolling back one of the statements involved in the deadlock. The example below demonstrates how deadlock occurs.

Suppose there is a table test with two rows.

create table test (

row_row_num row_number,

txt varchar2(10) );

insert into test values ( 1, 'First' );

insert into test values ( 2, 'Second' );

commit;

SQL> Select * from test ;

ROW_NUM TXT

1 First

2 Second

Ses#1: Issue the following command:

SQL> update test set txt='ses1' where row_num=1;

Ses#2: Issue the following command:

SQL> update test set txt='ses2' where row_num=2;

SQL> update test set txt='ses2' where row_num=1;

Ses#2 is now waiting for the lock held by Ses#1

Ses#1: Issue the following command:

SQL> update test set txt='ses1' where row_num=2;

This update would cause Ses#1 to wait on the lock held by Ses#2, but Ses#2 is already waiting on this session. This causes a deadlock

Print Email Download Reference This Send to Kindle Reddit This

Share This Essay

To share this essay on Reddit, Facebook, Twitter, or Google+ just click on the buttons below:

Request Removal

If you are the original writer of this essay and no longer wish to have the essay published on the UK Essays website then please click on the link below to request removal:

Request the removal of this essay.


More from UK Essays