Month: August 2014

Linux Administration

Posted on Updated on

Important commands for NFS

  showmount -e : Shows the available shares on your local machine

  showmount -e <server-ip or hostname>: Lists the available shares at the remote server

  showmount -d : Lists all the sub directories

  exportfs -v : Displays a list of shares files and options on a server

  exportfs -a : Exports all shares listed in /etc/exports, or given name

  exportfs -u : Unexports all shares listed in /etc/exports, or given name

  exportfs -r : Refresh the server’s list after modifying /etc/exports

NFS server configuration commands:

#rpm –qa | grep nfs

#ifconfig

#pwd

[root@nfsserver ~]# mkdir /nfsshare

#cd nfsshare

#touch f1 f2 f3

#vi /etc/exports

            Edit the file with line:

                        /root/nfsshare client’s ip address(rw,sync,no_root_squash)

   Save file.

NFS Options

Some other options we can use in “/etc/exports” file for file sharing is as follows.

  1. ro: With the help of this option we can provide read only access to the shared files i.e client will only be able to read.
  2. rw: This option allows the client server to both read and write access within the shared directory.
  3. sync: Sync confirms requests to the shared directory only once the changes have been committed.
  4. no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger file system, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
  5. no_root_squash: This phrase allows root to connect to the designated directory.

#service nfs restart

Setting Up the NFS Client

After configuring the NFS server, we need to mount that shared directory or partition in the client server.

Mount Shared Directories on NFS Client

Now at the NFS client end, we need to mount that directory in our server to access it locally. To do so, first we need to find out that shares available on the remote server or NFS Server

root@nfsclient ~]# showmount -e 192.168.0.100

Export list for 192.168.0.100:/nfsshare 192.168.0.101

Note: here 192.168.0.100 is server’s ip address while 192.168.0.101 is client’s ip address.

Above command shows that a directory named “nfsshare” is available at “192.168.0.100” to share with your server.

Mount Shared NFS Directory

To mount that shared NFS directory we can use following mount command.

root@nfsclient ~]# mount -t nfs 192.168.0.100:/nfsshare           /mnt/nfsshare

The above command will mount that shared directory in “/mnt/nfsshare” on the client server. You can verify it following command.      

[root@nfsclient ~]# mount | grep nfs sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)nfsd on /proc/fs/nfsd type nfsd (rw)192.168.0.100:/nfsshare on /mnt type nfs (rw,addr=192.168.0.100)

 

The above mount command mounted the nfs shared directory on to nfs client temporarily, to mount an NFS directory permanently on your system across the reboots, we need to make an entry in “/etc/fstab“.

Testing NFS mount:

#cd /mnt/nfsshare

#ls

f1 f2 f3

Removing the NFS Mount

If you want to unmount that shared directory from your server after you are done with the file sharing, you can simply unmount that particular directory with “umount” command. See this example below.

root@nfsclient ~]# umount /mnt/nfsshare

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

Advertisements

Modern Operating System

Posted on

A process is a program in execution, whereas a thread is a path of execution within a process.

Processes are generally used to execute large, ‘heavyweight’ jobs such as running different applications, while threads are used to carry out much smaller or ‘lightweight’ jobs such as auto saving a document in a program, downloading files, etc. Whenever we double-click an executable file such as Paint, for instance, the CPU starts a process and the process starts its primary thread.

1

Fig: A thread within a process

Each process runs in a separate address space in the CPU. But threads, on the other hand, may share address space with other threads within the same process. This sharing of space facilitates communication between them. Therefore, Switching between threads is much simpler and faster than switching between processes

Threads also have a great degree of control over other threads of the same process. Processes only have control over child processes.

Also, any changes made to the main thread may affect the behavior of other threads within the same process. However, changes made to the parent processes do not affect the child processes.

Considering the similarities, a thread can do anything that a process can do. They are both able to reproduce (Processes create child processes and threads create more threads), and they both have ID, base priority, execution time and exit status as attributes.

Example1:

To understand the actual differences between processes and threads, let us consider a real-life example. Suppose you are driving from city A to city B and you have had only three hours of sleep the night before after a terribly hectic day. Imagine yourself as the CPU and driving to city B as a process.

While driving you may have to do a number of smaller tasks such as checking the map on the GPS, making sure that you don’t exceed speed limits, making sure you don’t fall asleep (trust me, it happens!), etc.

These little tasks are actually threads of your process because collectively they serve to help in its execution. If any thread fails to execute properly, the entire process may be disrupted. (For instance, imagine what would happen if you actually fell asleep!)

Now let’s assume that there had been a storm the night before. After travelling some distance you see that a toppled over tree is blocking the road ahead. You cannot move any further unless the tree is removed. Therefore, your current process has to be stopped. Now you’ve got a brand new process in your hands- getting the tree out of the way.

So you gather people from a nearby village, which can be thought of as a thread to your new process, and shove the tree out of the way. Then you go back to your car and continue with your journey.

Example2:

Let us take another example. Suppose you are cooking pasta in your kitchen. Once again, imagine that you are the CPU and cooking pasta is your process. Your threads this time will be rolling and cutting the pasta dough, preparing the sauce, grating cheese, etc. All of a sudden from the corner of your eye you notice something moving.

You turn towards that direction and to your utter horror you see a huge rat! Now you cannot cook with the knowledge that there is a huge, nasty rat at large in your kitchen. So you stop doing whatever you were doing and set about accomplishing a new task, or a new process- Getting rid of the nasty little rodent.

So you cut a little slice of cheese, take a stick and wait for the rat in ambush. All of these are your threads. Finally when the rat does show up, you try to hit it and miss terribly, but you do succeed in scaring it away from your kitchen. Satisfied, you peacefully get back to your cooking.

Example3 :

Considering threads in windows and linux

In Linux, there is no distinction between processes and threads; instead it simply uses the term task. On the contrary, in windows there are considerable differences between these two as has been mentioned above.

The limited distinction between threads and processes in Linux exists because the entire context of the process is not present in the main process data structure. Instead the context is contained in independent data structures. The process data structure simply contains pointers to these separate structures. In windows, on the other hand, all the data vital to the process are contained exclusively within the process itself.

In Linux, the scheduler represents a higher priority of execution by a lower number, whereas in Windows it is represented by a higher number.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

 

    

ASP.NET – Directives

Posted on

ASP.NET – Directives

  • Net directives are instructions to specify optional settings, such as registering a custom control and page language. These settings describe how the web forms (.aspx) or user controls (.ascx) pages are processed by the .Net framework.
  • The syntax for declaring a directive is:

<%@  directive_name attribute=value  [attribute=value]  %>

  • The Application Directive
  • The Application directive defines application-specific attributes. It is provided at the top of the aspx file.
  • The basic syntax for a sample Application directive is:

<%@ Application Language=”C#” %>

  • The attributes of the Application directive are:

Attributes

Description

Inherits

the name of the class from which to inherit

Description

text description of the application. Parsers and compilers ignore this

Language

language used in code blocks

  • The Assembly Directive
  • The Assembly directive links an assembly to the page or the application at parse time.
  • This could appear either in the asax file for application-wide linking or in the page file or a user control file for linking to a page or user control.
  • The basic syntax for a sample Assembly directive is:

<%@ Assembly Name =”myassembly” %>

  • The attributes of the Assembly directive are:

Attributes

Description

Name

the name of the assembly to be linked

Src

the path to the source file to be linked and compiled dynamically

  • The Control Directive
  • The Control directive is used with the user controls and appears in the user control (.ascx) files.
  • The basic syntax for a sample Control directive is:

<%@ Control Language=”C#”  EnableViewState=”false” %>

  • The attributes of the Control directive are:

Attributes

Description

AutoEventWireup

the Boolean value that enables or disables automatic association of events to handlers

ClassName

file name for the control

Debug

the Boolean value that enables or disables compiling with debug symbols

Description

text description of the control page, ignored by compiler

EnableViewState

the Boolean value that indicates whether view state is maintained across page requests

Explicit

for VB language, tells the compiler to use Option Explicit mode

Inherits

the class from which the control page inherits

Language

language for code and script

Src

the filename for the code-behind class

Strict

for VB language, tells the compiler to use the Option Strict mode

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Normalization

Posted on

NORMALIZATION

Second Normal Form (2NF)

  • A relation is said to be in 2NF f if it is already in 1NF and each and every attribute fully depends on the primary key of the relation. Speaking inversely, if a table has some attributes which is not dependant on the primary key of that table, and then it is not in 2NF.
  • Emp-Id is the primary key of the above relation. Emp-Name, Month, Sales and Bank-Name all depend upon Emp-Id. But the attribute Bank-Name depends on Bank-Id, which is not the primary key of the table.
  • So the table is in 1NF, but not in 2NF. If this position can be removed into another related relation, it would come to 2NF.

Emp-Id

Emp-Name

Month

Sales

Bank-Id

E01

AA

JAN

1000

B01

E01

AA

FEB

1200

B01

E01

AA

MAR

850

B01

E02

BB

JAN

2200

B02

E02

BB

FEB

2500

B02

E03

CC

JAN

1700

B01

E03

CC

FEB

1800

B01

E03

CC

MAR

1850

B01

E03

CC

APR

1726

B01

Bank-Id

Bank-Name

B01

SBI

B02

UTI

  • After removing the portion into another relation we store lesser amount of data in two relations without any loss information. There is also a significant reduction in redundancy.

Third Normal Form (3NF)

  • A relation is said to be in 3NF, if it is already in 2NF and there exists notransitive dependency in that relation.
  • Speaking inversely, if a table contains transitive dependency, then it is not in 3NF, and the table must be split to bring it into 3NF.

A → B [B depends on A] 
And 
B → C [C depends on B] 
Then we may derive 
A → C[C depends on A]
Such derived dependencies hold well in most of the situations. For example if we have 
Roll → Marks 
And
Marks → Grade
Then we may safely derive 
Roll → Grade.

  • This third dependency was not originally specified but we have derived it.
  • The derived dependency is called a transitive dependency when such dependency becomes improbable. For example we have been given

Roll → City
And
City → STDCode

If we try to derive Roll → STDCode it becomes a transitive dependency, because obviously the STDCode of a city cannot depend on the roll number issued by a school or college. In such a case the relation should be broken into two, each containing one of these two dependencies:

Roll → City
And
City → STD code

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

VIRTUAL FUNCTIONS AND POLYMORPHISM

Posted on

For the students of FYBSc (IT), SYBSc (CS), SYBCA

VIRTUAL FUNCTIONS AND POLYMORPHISM

  • The wordpolymorphism means having many forms and it occurs when there is a hierarchy of classes and they are related by inheritance.
  • C++ polymorphism means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function.
  • Consider the following example where a base class has been derived by other two classes:

include <iostream>
class Shape {
protected:
int width, height;
public:
Shape( int a=0, int b=0)
{ width = a;
height = b; }
int area()
{ cout << “Parent class area :” <<endl;
return 0; }};
class Rectangle: public Shape{
public:
Rectangle( int a=0, int b=0):Shape(a, b) { }
int area ()
{ cout << “Rectangle class area :” <<endl;
return (width * height); }};
class Triangle: public Shape{
public:
Triangle( int a=0, int b=0):Shape(a, b) { }
int area ()
{ cout << “Triangle class area :” <<endl;
return (width * height / 2); }};
// Main function for the program
void main( )
{
Shape *shape;
Rectangle rec(10,7);
Triangle tri(10,5);

// store the address of Rectangle
shape = &rec;
// call rectangle area.
shape->area();

// store the address of Triangle
shape = &tri;
// call triangle area.
shape->area(); }

When the above code is compiled and executed, it produces the following result:

Parent class areaParent class area

  • The reason for the incorrect output is that the call of the function area() is being set once by the compiler as the version defined in the base class. This is calledstatic resolution of the function call, or static linkage – the function call is fixed before the program is executed.
  • This is also sometimes called early bindingbecause the area() function is set during the compilation of the program.
  • The declaration of area() in the Shape class with the keywordvirtual as follows –

class Shape {
protected:
int width, height;
public:
Shape( int a=0, int b=0)
{ width = a;
height = b; }
virtual int area()
{ cout << “Parent class area :” <<endl;
return 0; }};

After this slight modification, when the previous example code is compiled and executed, it produces the following result:

Rectangle class area

Triangle class area

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

ASP.NET CORE SERVICES

Posted on

  1. NET CORE SERVICES
  • It includes features, such as output caching and session-state storage. The benefits of the net core services are as follows:
  • Refactoring of web.config file: specifies that in this version of .net, the most of the configuration elements of the web.config file have been placed to the machine.config file. This shows that the web.config file in this new version of asp.net is either empty or consists  of  some  of  the  basic  code,  which  specifies  the  version  of  the  .net framework the application is targeting.
  • Output caching: enables to configure one or more output cache providers. The output caching  feature  in  NET enables  the  developers  to  store  the  generated output of controls and HTTP responses in the memory. This is very helpful as in case of subsequent web requests, the content can be retrieved from the output cache.
  • Auto-start web  applications: it  provides  a  better  way  for  starting  an  NET application, and accepting HTTP requests. In the earlier versions of ASP.NET, while loading large amount of data or performing advanced initializing processing needed to run initialization code in the Application_start() method in the Global.asax file.
  • Redirecting page: removes the unnecessary redirects of the browser. In the previous versions, the Response.Redirect () method was used to forward a request to a new URL. The Response.Redirect () method uses the HTTP302 response, which results in an extra HTTP round trip.
  • Compressing session state: reduces the size of session-state. In ASP.NET, there are two options  that  help  in  storing session  state  in  a  web    First option, the session-state provider invokes an out-of-process session-state server. Second option, the session-state provider stores the data in Microsoft SQL Server database.

Range of allowable URLs: refers to the increase in the size of application URLs. In the  previous  versions  of  ASP.NET,  the  maximum  length  of  the  URL  path  was  260 characters.  In  ASP.NET4.0,  increase  the  URL  path  length  by  using  the  new httpRuntime configuration attribute such as max RequestPathLength attribute.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

 

Normalization

Posted on Updated on

NORMALIZATION

  • While designing a database out of an entity–relationship model, the main problem existing in that “raw” database is redundancy.
  • Redundancy is storing the same data item in more one place. A redundancy creates several problems like the following:
  1. Extra storage space: storing the same data in many places takes large amount of disk space.
  2. Entering same data more than once during data insertion.
  3. Deleting data from more than one place during deletion.
  4. Modifying data in more than one place.
  5. Anomalies may occur in the database if insertion, deletion, modification etc are no done properly. It creates inconsistency and unreliability in the database.
  • To solve this problem, the “raw” database needs to be normalized. This is a step by step process of removing different kinds of redundancy and anomaly at each step.
  • At each step a specific rule is followed to remove specific kind of impurity in order to give the database a slim and clean look.

Un-Normalized Form (UNF)

  • If a table contains non-atomic values at each row, it is said to be in UNF. Anatomic value is something that cannot be further decomposed. A non-atomic value, as the name suggests, can be further decomposed and simplified.
  • Consider the following table:

Emp-Id

Emp-Name

Month

Sales

Bank-Id

Bank-Name

E01

AA

Jan

1000

B01

SBI

   

Feb

1200

   
   

Mar

850

   

E02

BB

Jan

2200

B02

UTI

   

Feb

2500

   

E03

CC

Jan

1700

B01

SBI

   

Feb

1800

   
   

Mar

1850

   
   

Apr

1725

   
  • In the sample table above, there are multiple occurrences of rows under each key Emp-Id. Although considered to be the primary key, Emp-Id cannot give us the unique identification facility for any single row.
  • Further, each primary key points to a variable length record (3 for E01, 2 for E02 and 4 for E03).

First Normal Form (1NF)

  • A relation is said to be in 1NF if it contains no non-atomic values and each row can provide a unique combination of values.
  • The above table in UNF can be processed to create the following table in 1NF.

Emp-Id

Emp-Name

Month

Sales

Bank-Id

Bank-Name

E01

AA

Jan

1000

B01

SBI

E01

AA

Feb

1200

B01

SBI

E01

AA

Mar

850

B01

SBI

E02

BB

Jan

2200

B02

UTI

E02

BB

Feb

2500

B02

UTI

E03

CC

Jan

1700

B01

SBI

E03

CC

Feb

1800

B01

SBI

E03

CC

Mar

1850

B01

SBI

E03

CC

Apr

1725

B01

SBI

  • As you can see now, each row contains unique combination of values.
  • Unlike in UNF, this relation contains only atomic values, i.e. the rows cannot be further decomposed, so the relation is now in 1NF.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com