Learn Unix: Diffrence between Compiler and Interpreter
this is test link
Monday, 3 October 2011
Sunday, 21 August 2011
Diffrence between Compiler and Interpreter
Compiler
Compiler is computer program or set of programs written in some programming language , which converts souce code into target machine level language or binary language .
Interpreter
Interprter is computer program to execute compiled machine code .
Compiler is computer program or set of programs written in some programming language , which converts souce code into target machine level language or binary language .
Interpreter
Interprter is computer program to execute compiled machine code .
Buffer Managment Algorithum
Buffer Managment Algorithum
1 ] bmap - buffer mapping algorithm
2 ] bread - buffer reading algorithm
3 ] bwrite - buffer writing algorithm
4 ] brelease - buffer release algorithm
This are some buffer managment algorithm . This algorithm help in memory managment . Memory managment is important in Unix operating system .
Sunday, 1 May 2011
Working with vectors and arrays
Working with vectors and arrays
----------------------------------------------------------------------------------------
import java.util.*;
class LanguageVector
{
public static void main(String args[])
{
Vector list = new Vector();
int lenght = args.length ;
for( int i= 0 ; i < length ; i++)
{
list.addElement(args[i]) ;
}
list.insertElement("COBOL ", 2 ) ;
int size = list.size();
String listArray[] = new String[size];
list.copyInto(listArray);
System.out.println(" List of Languages ") ;
for( int i = 0 ; i < siez ; i++ )
{
System.out.println(listArray[i]);
}
}
}
----------------------------------------------------------------------------------------
import java.util.*;
class LanguageVector
{
public static void main(String args[])
{
Vector list = new Vector();
int lenght = args.length ;
for( int i= 0 ; i < length ; i++)
{
list.addElement(args[i]) ;
}
list.insertElement("COBOL ", 2 ) ;
int size = list.size();
String listArray[] = new String[size];
list.copyInto(listArray);
System.out.println(" List of Languages ") ;
for( int i = 0 ; i < siez ; i++ )
{
System.out.println(listArray[i]);
}
}
}
Sunday, 24 April 2011
Defining Classes
Defining Classes
The basic structure of defining a class is as follows :
scope class className [extends class]
{
//class implementation statements
}
When declaring the scope of the class , we have several options to control how other classes can access this class:
public --- the class can be used by code outside of the file . only one class in a file may have this scope . The file must be named with the class name followed by the four-letter .java extension.
private --- the class can only be used by itself and must be subclassed .
The basic structure of defining a class is as follows :
scope class className [extends class]
{
//class implementation statements
}
When declaring the scope of the class , we have several options to control how other classes can access this class:
public --- the class can be used by code outside of the file . only one class in a file may have this scope . The file must be named with the class name followed by the four-letter .java extension.
private --- the class can only be used by itself and must be subclassed .
The Context Of A Process
The Context Of A Process
The context of a process consists of the contents of its (user) address space and the contents of hardware registers and kernel data structures that relate to the process . Formally the context of a process is the union of its user - level context , register context and system level context . The user - level context consists of the process text , data , user stack , and shared memory that occupy the virtual address space of the process . Parts of the virtual address
The context of a process consists of the contents of its (user) address space and the contents of hardware registers and kernel data structures that relate to the process . Formally the context of a process is the union of its user - level context , register context and system level context . The user - level context consists of the process text , data , user stack , and shared memory that occupy the virtual address space of the process . Parts of the virtual address
Sample Interrupt Vector
Sample Interrupt Vector
Interrupt Number Interrupt Handle
0 clockintr
1 diskintr
2 ttyintr
3 devintr
4 softintr
5 otherintr
Interrupt Number Interrupt Handle
0 clockintr
1 diskintr
2 ttyintr
3 devintr
4 softintr
5 otherintr
Algorithm for Handling Interrupts
Algorithm for Handling Interrupts
algorithm inthand /* handle interrupts */
input : none
output : none
{
save (push) current context layer ;
determine interrupt source ;
find interrupt vector;
call interrupt handler ;
restore (pop) previous contex layer
}
algorithm inthand /* handle interrupts */
input : none
output : none
{
save (push) current context layer ;
determine interrupt source ;
find interrupt vector;
call interrupt handler ;
restore (pop) previous contex layer
}
Algorithm for system calls
Algorithm for system calls /* algorithm for invocation of system call */
input : system call number
output : result of system call
{
find entry in system call table corresponding to system call number ;
determine number of parameters to system call ;
copy parameters from user address space to u area ;
invoke system call code in kernel ;
if (error during execution of system call )
{
set register 0 in user saved register context to error number ;
turn on carry bit in PS register in user saved register context;
}
else
set registers 0 ,1 in user saved register context to return values from system call ;
}
input : system call number
output : result of system call
{
find entry in system call table corresponding to system call number ;
determine number of parameters to system call ;
copy parameters from user address space to u area ;
invoke system call code in kernel ;
if (error during execution of system call )
{
set register 0 in user saved register context to error number ;
turn on carry bit in PS register in user saved register context;
}
else
set registers 0 ,1 in user saved register context to return values from system call ;
}
Algorithm allocreg
Algorithm allocreg /* allocate a region data structure */
input : (1) inode pointer
(2) region type
output : locked region
{
remove region from linked list of free regions ;
assign region type ;
assign region inode pointer ;
if(inode pointer not null)
increment inode refernce count ;
place region on linked list of active region ;
return (locked region);
}
input : (1) inode pointer
(2) region type
output : locked region
{
remove region from linked list of free regions ;
assign region type ;
assign region inode pointer ;
if(inode pointer not null)
increment inode refernce count ;
place region on linked list of active region ;
return (locked region);
}
Alogithm Growreg for changing the size of a Region
Alogithm Growreg for changing the size of a Region
algorith growred /* change the size of a region */
input : (1) pointer to per process region table entry
(2) change in size of region (man be positive or negative)
output: none
{
if(region size increasing)
{e
check legality of new region size ;
allocate auxiliary tables(page tables);
if(not system supporting demand paging)
{
allocate physical memory ;
initialize auxiliary tables , as necessary ;
}
}
else /* region size decreasing */
{
free physical memory , as appropriate ;
free auxiliary tables , as necessary ;
}
do (othere) initialization of auxialiary tables , as necessary ;
set size field in process table;
}
algorith growred /* change the size of a region */
input : (1) pointer to per process region table entry
(2) change in size of region (man be positive or negative)
output: none
{
if(region size increasing)
{e
check legality of new region size ;
allocate auxiliary tables(page tables);
if(not system supporting demand paging)
{
allocate physical memory ;
initialize auxiliary tables , as necessary ;
}
}
else /* region size decreasing */
{
free physical memory , as appropriate ;
free auxiliary tables , as necessary ;
}
do (othere) initialization of auxialiary tables , as necessary ;
set size field in process table;
}
Saturday, 23 April 2011
Algorithm for allocating a Region
Algorithm for allocating a Region
algorithm allocreg /* allocate a region data structure */
input : (1) inode pointer
(2) region type
output : (1) locked region
{
remove region from linked list of free region ;
assign region type ;
assign region indoe pointer ;
if (inode pointer not null)
increment inode reference count ;
place region on linked list of active regions ;
return(locked region);
}
algorithm allocreg /* allocate a region data structure */
input : (1) inode pointer
(2) region type
output : (1) locked region
{
remove region from linked list of free region ;
assign region type ;
assign region indoe pointer ;
if (inode pointer not null)
increment inode reference count ;
place region on linked list of active regions ;
return(locked region);
}
algorithm attachreg
algorithm attachreg /* attach a region to a process*/
input : (1) pointer to (locked) region being attached
(2) process to which region is being attached
(3) virtual address in process where region will be attached
(4) region type
output : per process region table entry
{
allocate per process region table entry for process ;
initialize per process region table entry ;
set pointer to region being attached ;
set type field ;
set virtual address field ;
check legality of virtual address , region table ;
increment region reference count ;
increment process size according to attached region;
initialize new hardware register triple for process ;
return (per process region table entry );
}
input : (1) pointer to (locked) region being attached
(2) process to which region is being attached
(3) virtual address in process where region will be attached
(4) region type
output : per process region table entry
{
allocate per process region table entry for process ;
initialize per process region table entry ;
set pointer to region being attached ;
set type field ;
set virtual address field ;
check legality of virtual address , region table ;
increment region reference count ;
increment process size according to attached region;
initialize new hardware register triple for process ;
return (per process region table entry );
}
Conversion of Byte Offset to Block Number in File System
Conversion of Byte Offset to Block Number in File System
algorithm bmap /* block map of logical file byte of offset to file system block*/
input : (1) inode
(2) byte offset
output: (1) block number in file system
(2) byte offset into block
(3) byte of I/O in block
(4) read ahead block number
{
calculate logical block number in file from byte offset ;
calculate start byte in block for I/O ;
calculate number of bytes to copy to user ;
check if read - ahead applicale , mark inode ;
determine level of indirection ;
while( not at necessary level of indirection)
{
calculate index into inode or indirect block from logical block number in file ;
get disk block number from inode or indirect block ;
release buffer from previous disk read , if any (algorithm brelease );
if(no more levels of indirection)
return(block number);
read indirect disk block(algorithm bread);
adjust logical block number in file according to level of indirection ;
}
}
algorithm bmap /* block map of logical file byte of offset to file system block*/
input : (1) inode
(2) byte offset
output: (1) block number in file system
(2) byte offset into block
(3) byte of I/O in block
(4) read ahead block number
{
calculate logical block number in file from byte offset ;
calculate start byte in block for I/O ;
calculate number of bytes to copy to user ;
check if read - ahead applicale , mark inode ;
determine level of indirection ;
while( not at necessary level of indirection)
{
calculate index into inode or indirect block from logical block number in file ;
get disk block number from inode or indirect block ;
release buffer from previous disk read , if any (algorithm brelease );
if(no more levels of indirection)
return(block number);
read indirect disk block(algorithm bread);
adjust logical block number in file according to level of indirection ;
}
}
Disk Inode
Sample Disk Inode
owner mjb
group os
type regular file
perms rwxr-xr-x
accessed Oct 23 1984 1:45 P.M.
modified Oct 23 1984 10.30 A.M.
inode Oct 23 1984 1.30 P.M.
size 6030 bytes
disk addresses
owner mjb
group os
type regular file
perms rwxr-xr-x
accessed Oct 23 1984 1:45 P.M.
modified Oct 23 1984 10.30 A.M.
inode Oct 23 1984 1.30 P.M.
size 6030 bytes
disk addresses
Difference between Java And C/C++
Difference between Java And C/C++
Data Types
Data Types
- All java primitives data types (char , int , short , long , byte, float , double and boolean ) have specified sizes and behaviour that are machine-independent .
- Conditional expression can only be boolean , not integral .
- Casting between data types is much more controlled in Java . Automatic conversion occurs only when there is no loss of information . All other casts must be explicit .
- Java supports special methods to convert values between class objects and primitive types .
- Composite data types are accomplished in java using only classes . Structures and unions are not supported .
Java Keywords
Java Keywords
Class organisation - package -
specifies the class in a particular source file should belong to the named package .
import -- requests the named class or classes be imported into the current applications .
Class definations -- interface --
defines global data and method signatures that can be shared among classes .
class -- defines a collection of related data behavior .
extends -- indicates which class to subclass .
implements -- indicates the interface for which a new class will supply methods .
Program that creates a new process to copy files
Program that creates a new process to copy files
main(argc,argv)
int argc;
char *argv[];
{
/* assume 2 args ; source file and target file*/
if(fork()== 0)
execl("copy","copy",argv[1],argv[2],0);
wait((int *) 0);
printf("copy done\n");
}
Explanation :-
main(argc,argv)
int argc;
char *argv[];
{
/* assume 2 args ; source file and target file*/
if(fork()== 0)
execl("copy","copy",argv[1],argv[2],0);
wait((int *) 0);
printf("copy done\n");
}
Explanation :-
Program to copy a file
Program to copy a file
#include<fcntl.h>
char buffer[2048];
int version=1;
main(argc,argv)
int argc;
char *argv[];
{
int fold,fdnew;
if(argc!=3)
{
printf("need 2 arguments for copy program\n");
exit(1);
}
fdold=open(argv[1],O_RDONLY);
if(fdold==-1)
{
printf("cannot open file %s\n",argv[1]);
exit(1);
}
fdnew=creat(argv[2],0666);
if(fdnew==-1)
{
printf("cannot create file %s\n",argv[2]);
exit(1);
}
copy(fdold,fdnew);
exit(0);
}
copy(old,new)
int old,new;
{
int count;
while((count=read(old,buffer,sizeof(buffer)))>0)
write(new,buffer,count);
}
#include<fcntl.h>
char buffer[2048];
int version=1;
main(argc,argv)
int argc;
char *argv[];
{
int fold,fdnew;
if(argc!=3)
{
printf("need 2 arguments for copy program\n");
exit(1);
}
fdold=open(argv[1],O_RDONLY);
if(fdold==-1)
{
printf("cannot open file %s\n",argv[1]);
exit(1);
}
fdnew=creat(argv[2],0666);
if(fdnew==-1)
{
printf("cannot create file %s\n",argv[2]);
exit(1);
}
copy(fdold,fdnew);
exit(0);
}
copy(old,new)
int old,new;
{
int count;
while((count=read(old,buffer,sizeof(buffer)))>0)
write(new,buffer,count);
}
Tuesday, 8 March 2011
A parameter is an entity that stores values. It can be a name, a number, or one of the special characters listed below. For the shell's purposes, a variable is a parameter denoted by a name.
Sunday, 6 March 2011
Memory management subsystem implements the virtual memory concept and a user need not worry about the executable program size and the RAM size.
There are many systems which are Unix-like in their architecture .
A Unix kernel — the core or key components of the operating system — consists of many kernel subsystems like process management, memory management, file management, device management and network management.
A Unix kernel — the core or key components of the operating system — consists of many kernel subsystems like process management, memory management, file management, device management and network management.
A fundamental simplifying assumption of Unix was its focus on ASCII text for nearly all file formats. There were no "binary" editors in the original version of Unix – the entire system was configured using textual shell command scripts. The common denominator in the I/O system was the byte – unlike "record-based" file systems.
Unix was the first operating system to include all of its documentation online in machine-readable form .
man – manual pages for each command, library component, system call, header file, etc
man – manual pages for each command, library component, system call, header file, etc
Commands – Unix makes little distinction between commands (user-level programs) for system operation and maintenance commands of general utility , and more general-purpose applications such as the text formatting and typesetting package.
Unix provided the TCP/IP networking protocol on relatively inexpensive computers, which contributed to the Internet explosion of worldwide real-time connectivity, and which formed the basis for implementations on many other platforms. This also exposed numerous security holes in the networking implementations
It was written in high level language rather than assembly language (which had been thought necessary for systems implementation on early computers). Although this followed the lead of Multics and Burroughs, it was Unix that popularized the idea.
The Unix system is composed of several components that are normally packed together. By including – in addition to the kernel of an operating system – the development environment, libraries, documents, and the portable, modifiable source-code for all of these components, Unix was a self-contained software system. This was one of the key reasons it emerged as an important teaching and learning tool and has had such a broad influence
Unix operating systems are widely used in servers, workstations, and mobile devices.[2] The Unix environment and the client–server program model were essential elements in the development of the Internet and the reshaping of computing as centered in networks rather than in individual computers.
Both Unix and the C programming language were developed by AT&T and distributed to government and academic institutions, which led to both being ported to a wider variety of machine families than any other operating system. As a result, Unix became synonymous with "open systems".
Both Unix and the C programming language were developed by AT&T and distributed to government and academic institutions, which led to both being ported to a wider variety of machine families than any other operating system. As a result, Unix became synonymous with "open systems".
Saturday, 5 March 2011
Subscribe to:
Posts (Atom)