Monday, 7 October 2013

Creation of a child process using fork system call

#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>

int main()
{
    int p[2];
    pid_t pid;

    char inbuf[10],outbuf[10];

     if(pipe(p)==-1)
    {
               printf("pipe failed\n");
               return 1;
     }

    else
         printf(" pipe created\n");

if((pid=fork()))
{
    printf("In parent process\n");
    printf("type the data to be sent to child");
    scanf("%s",outbuf);
     write (p[1],outbuf,10);
      sleep(2);
      printf("after sleep in parent process\n");
}

else  
{
       printf("In child process\n");
       read(p[0],inbuf,10);
       printf("the data received by the child is %s\n",inbuf);
       sleep(2);
       printf("After sleep in child\n");
}
return 0;
}

Tags : OS LAB Program , Os programs , Creation of a child process using fork system call , OS fork program , fork system call , use of fork system call , fork() , working of fork() , fork() system call.

Monday, 23 September 2013

Linux | Pipe - Read & Write Program


Read Pipe :

#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<error.h>

int main()
{
int fd;

fd = open("MyPipe",O_RDONLY,0666);

if(fd<0)
{
perror("Open");
return 0;
}


char c;
int s;

while(1)
{
s=read(fd,&c,1);
if(!s)
break;
printf("%c",c);
}

printf("\n\n");

close(fd);

}


Write Pipe :


#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<error.h>

int main()
{
int fd;

fd = open("MyPipe",O_WRONLY,0666);

if(fd<0)
{
perror("Open");
return 0;
}


char c[]="Welcome";
int s;


s=write(fd,c,7);

printf("\n\n");

close(fd);

}

Linux | File Programs

                 

                    File Program 1

#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<error.h>

int main()
{
int fd;

fd = open("test",O_RDONLY|O_CREAT,0477);

if(fd<0)
{
perror("Open");
return 0;
}


char c;
int s;

s=read(fd,&c,1);

if(s)
{
printf("\nRead Character: %c",c);
}

printf("\n\n");

close(fd);

}




 File Program 2


#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<error.h>

int main()
{
int fd;

fd = open("test",O_WRONLY|O_CREAT,0666);

if(fd<0)
{
perror("Open");
return 0;
}


char c[] = "Welcome To Files...";
int s;

s=write(fd,c,sizeof(c));

if(s)
{
printf("\nWritten Character: %d",s);
}

printf("\n\n");

close(fd);

}


 File Program 3


#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<error.h>

int main()
{
int fd;

fd = open("test",O_RDONLY|O_CREAT,0666);

if(fd<0)
{
perror("Open");
return 0;
}


char c;
int s;

while(1)
{
s=read(fd,&c,1);
if(!s)
break;
printf("%c",c);
}

printf("\n\n");

close(fd);

}




 File Program 4


#include<stdio.h>
#include<error.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>

int main()
{
int fd;

fd = open("test",O_RDWR,0644);
//fd = creat("test",0644);

if(fd<0)
{
perror("File Open");
exit(1);
}

int s,len;
char txt[100];

printf("\nEnter Text to be written to File: ");
gets(txt);

len = strlen(txt);

s = write(fd,txt,len);

printf("%d characters written to file...\n\n",s);

s = lseek(fd,0,SEEK_SET);

printf("\n[%d]\n",s);
strcpy(txt,"\0") ;
s = read(fd,txt,100);
printf("%s-%d",txt,s);
close(fd);
return 0;
}


 File Program 5

#include<stdio.h>
#include<error.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
struct stu
{
char name[40];
int rno;
double cg;
};
int main()
{
int fd;
struct stu s2,s1={"VS",333,9.9};

fd = open("test",O_RDWR|O_CREAT,0644);

if(fd<0)
{
perror("File Open");
exit(1);
}

int s;

s = write(fd,"This is Test File",10);
printf("%d characters written to file...\n\n",s);

s = write(fd,&s1,sizeof(s1));
printf("%d characters written to file...\n\n",s);

lseek(fd,-1*sizeof(s1),SEEK_CUR);
s = read(fd,&s2,sizeof(s2));
printf("Read Record: %s - %d - %lf\n\n",s2.name,s2.rno,s2.cg);

close(fd);
return 0;
}




 File Program 6

#include<stdio.h>
#include<error.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>

int main()
{
int fd;

fd = open("test",O_CREAT|O_WRONLY,0644);

if(fd<0)
{
perror("File Open");
exit(1);
}

int s,len;
char txt[100];

printf("\nEnter Text to be written to File: ");
gets(txt);

len = strlen(txt);

s = write(fd,txt,len);

printf("%d characters written to file...\n\n",s);


close(fd);
return 0;
}



 File Program 7

#include<stdio.h>
#include<sys/stat.h>
#include<error.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<string.h>
#include<time.h>

int main()
{
int fd;
struct stat st;

fd = lstat("File1.c",&st);

//fd = creat("test",0644);

if(fd<0)
{
perror("File Open");
exit(1);
}

printf("\nSize: %d",st.st_size);
printf("\nInode: %d",st.st_ino);
printf("\nDevice Number: %d,%d",major(st.st_dev),minor(st.st_dev));
printf("\nUser ID: %o",st.st_uid);
printf("\nGroup ID: %o",st.st_gid);
printf("\nMode: %o",st.st_mode);

struct tm *t;
char tt[50];
t = localtime(&st.st_atime);
strftime(tt,50,"%c",t);
printf("\nModification Time: %s",tt);
char *mt = ctime(&st.st_mtime);
printf("\nAccess Time: %s",mt);
char *ct = ctime(&st.st_ctime);
printf("\nChange Time: %s",ct);

printf("\n\n");


return 0;
}

Linux Ebook | Michael K Johnson , Erik W. Troan


CLICK HERE TO DOWNLOAD


CLICK HERE TO DOWNLOAD
CLICK HERE TO DOWNLOAD
CLICK HERE TO DOWNLOAD

Linux Application Development (2nd Edition)
Erik W. Troan, Michael K. Johnson | Addison-Wesley Professional | 2011-11-29 | 736 pages | English | PDF

"The first edition of this book has always been kept within arm's reach of my desk due to the wonderful explanations of all areas of the Linux userspace API. This second edition greatly overshadows the first one, and will replace it."
--Greg Kroah-Hartman, Linux kernel programmer
Develop Software that Leverages the Full Power of Today's Linux
Linux Application Development, Second Edition, is the definitive reference for Linux programmers at all levels of experience, including C programmers moving from other operating systems. Building on their widely praised first edition, leading Linux programmers Michael Johnson and Erik Troan systematically present the key APIs and techniques you need to create robust, secure, efficient software or to port existing code to Linux.
This book has been fully updated for the Linux 2.6 kernel, GNU C library version 2.3, the latest POSIX standards, and the Single Unix Specification, Issue 6. Its deep coverage of Linux-specific extensions and features helps you take advantage of the full power of contemporary Linux. Along the way, the authors share insights, tips, and tricks for developers working with any recent Linux distribution, and virtually any version of Unix.
Topics include
  • Developing in Linux: understanding the operating system, licensing,
  • and documentation
  • The development environment: compilers, linker and loader, and unique
  • debugging tools
  • System programming: process models, file handling, signal processing, directory operations, and job control
  • Terminals, sockets, timers, virtual consoles, and the Linux console
  • Development libraries: string matching, terminal handling, command-line parsing, authentication, and more
  • Hundreds of downloadable code samples
New to this edition
  • The GNU C library (glibc), underlying standards, and test macros
  • Writing secure Linux programs, system daemons, and utilities
  • Significantly expanded coverage of memory debugging, including Valgrind and mpr
  • Greatly improved coverage of regular expressions
  • IPv6 networking coverage, including new system library interfaces for using IPv6 and IPv4 interchangeably
  • Coverage of strace, ltrace, real-time signals, poll and epoll system calls, popt library improvements, Pluggable Authentication Modules (PAM), qdbm, and much more
  • Improved index and glossary, plus line-numbered code examples

Thursday, 19 September 2013

Encrypt & Decrypting Messages

 /*
Exercise : Ex 3
Title : Sender Program..
Author :Aslam Jainul
*/

import java.io.*;
import java.net.*;
import java.util.*;
 class sender
{
public static void main(String args[])
{
try
{
int key;
DataInputStream dis=new DataInputStream(System.in);

key=2;
System.out.println("enter the name");
String f=dis.readLine();
File f1=new File(f);
FileReader fr=new FileReader(f1);
Socket s=new Socket("192.168.208.118",8081);
PrintWriter put=new PrintWriter(s.getOutputStream(),true);
put.println(f);
int c=0;
while((c=fr.read())!= -1)
{
put.println(c+key);
}
System.out.println("File content transferred");
fr.close();
s.close();
}
catch(Exception e)
{}
}
}


 /*
Exercise : Ex 3
Title : Receiver Program..
Author :Aslam Jainul
*/

import java.io.*;
import java.net.*;
import java.util.*;
 class receiver
{
public static void main(String args[]) throws IOException
{
ServerSocket ss;
Socket s;
try
{
System.out.println("waiting for client");
ss=new ServerSocket(8081);
s=ss.accept();
System.out.println("connection established");
BufferedReader get=new BufferedReader(new InputStreamReader(s.getInputStream()));
String fname;
fname=get.readLine();
fname="TR_"+fname;
System.out.println("file name is:"+fname);
File f=new File(fname);
FileWriter fw=new FileWriter(f);
String c;
while((c=get.readLine())!=null)

fw.write(Integer.parseInt(c));
System.out.println("received content stored");
fw.close();
s.close();
}
catch(Exception e)
{}
}
}

 /*
Exercise : Ex 3
Title : Decrypt File
Author :Aslam Jainul
*/

import java.io.*;
import java.net.*;
import java.util.*;
 class decript
{
public static void main(String args[])
{
try
{
DataInputStream dis=new DataInputStream(System.in);
System.out.println("Enter the encrypted file name with extension");
String fname=dis.readLine();
File f1=new File(fname);
FileReader fr=new FileReader(f1);
File f2=new File("dec_"+fname);
FileWriter fw=new FileWriter(f2);
int c=0;
while((c=fr.read())!=-1)
{
System.out.println(c-2);
fw.write(c-2);
}
fr.close();
fw.close();
}
catch(Exception e)
{}
}
}



UDP Receiver & Sender Program

 /*
Exercise : Ex 2(b)
Title : UDP Receiver Program..
Author :Aslam Jainul
*/
import java.io.*;
                 import java.net.*;
                 import java.util.*;
                 public class UdpReceiver
                 {
                     public static void main(String args[])throws IOException
                     {
                          try
                             {
                                 DataInputStream dis=new DataInputStream(System.in);                              
                                 byte[] rdata=new byte[1024];
                                                       
                       
                               DatagramSocket s=new DatagramSocket(9876);
                               DatagramPacket rpack=new DatagramPacket(rdata,rdata.length);
                             
                               System.out.println("Waiting for file name:");
                               s.receive(rpack);
                             
                               String fname=new String(rpack.getData());
                               System.out.println("From server : "+fname);
                                                       
                             fname="TR_"+fname;
                             System.out.println("File name is : "+fname);
                           
                             File f=new File(fname);
                             FileWriter fw=new FileWriter(f);
                           
                             
                             while(true)
                             {
                             
                             byte[] rdata1=new byte[1024];                          
                             DatagramPacket rpack1=new DatagramPacket(rdata1,rdata1.length);
                             
                             s.receive(rpack1);
                             String txt=new String(rpack1.getData());
                             fw.write(txt);
                             System.out.print(txt);
                             if(txt.trim().equals("done"))
                             {
                                  System.out.println("Process finished");
                                  fw.close();
                                  break;
                             }
                             
                             }
                         }
                         catch(IOException e)
                         {         System.out.println(""+e);
                         }
                     }  
                 }


 /*
Exercise : Ex 2(b)
Title : UDP Sender Program..
Author :Aslam Jainul
*/
  import java.io.*;
                   import java.net.*;
                   import java.util.*;
                   public class UdpSender
                   {
                        public static void main(String args[])
                        {
                             try
                             {
                                  DataInputStream dis=new DataInputStream(System.in);
                                  System.out.println("Enter the file name :");
                                  String f=dis.readLine();

                               
byte[] sdata=new byte[1024];                          
                            sdata=f.getBytes();
                               
                               InetAddress ipa=InetAddress.getByName("127.0.0.1");
                               DatagramSocket s=new DatagramSocket();
                               DatagramPacket spack=new DatagramPacket(sdata,sdata.length,ipa,9876);
                               s.send(spack);
                             
                                  File f1= new File(f);
                                  FileReader fr=new FileReader(f1);
                                  int n=0;
                                  byte[] buffer=new byte[1024];
                             
StringBuffer fileData = new StringBuffer(1000);
        BufferedReader reader = new BufferedReader(new FileReader(f));
        char[] buf = new char[1024];
        int numRead=0;
        while((numRead=reader.read(buf)) != -1)
        {
            String readData = String.valueOf(buf, 0, numRead);
            System.out.print(readData);
            buffer=readData.getBytes();
       DatagramPacket spack1=new DatagramPacket(buffer,buffer.length,ipa,9876);
          s.send(spack1);
        }                              
                             
byte[] endChar=new byte[1024];
endChar="done".getBytes();
spack=new DatagramPacket(endChar,endChar.length,ipa,9876);
s.send(spack);
         }
         catch(IOException e)
         {
          System.out.println(""+e);
         }
    }
}



TCP Receiver & Sender Program

/*
Exercise : Ex 2(a)
Title : TCP Receiver Program..
Author :Aslam Jainul
*/

import java.io.*;
import java.net.*;
import java.util.*;
public class TCPreceiver
{
public static void main(String args[])
{

ServerSocket ss;
Socket s;
try
{
System.out.println("Waiting for Client........");
ss=new ServerSocket(8081);
s=ss.accept();
System.out.println("Connection Done...!!");
BufferedReader get=new BufferedReader(new InputStreamReader(s.getInputStream()));
String fname;
System.out.println("From : " + s.getInetAddress() );

fname=get.readLine();
fname="TR_" +fname;
System.out.println("file name is:" +fname);
File f=new File(fname);
FileWriter fw=new FileWriter(f);
String c;
while((c=get.readLine())!=null)
fw.write(Integer.parseInt(c));
System.out.println("Contents Received..");
fw.close();
s.close();
}
catch(Exception e)
{}

}
}


/*
Exercise : Ex 2(a)
Title : TCP Sender Program..
Author :Aslam Jainul
*/

import java.io.*;
import java.net.*;
import java.util.*;
public class TCPsender
{
public static void main(String args[])
{
try
{
System.out.println("Enter the File Name you wanna transfer ...");
DataInputStream dis=new DataInputStream(System.in);
String f=dis.readLine();
File f1=new File(f);
FileReader fr=new FileReader(f1);
Socket s=new Socket("192.168.208.118",8081);
PrintWriter put=new PrintWriter(s.getOutputStream(),true);
put.println(f);
int c=0;
while((c=fr.read())!=-1)
put.println(c);
System.out.println("File Transfered....");
fr.close();
s.close();
}
catch(Exception e)
{}
}
}





Sunday, 15 September 2013

Operating System - Silberschatz - Seventh edition

Another defining moment in the evolution of operating systems
Small footprint operating systems, such as those driving the handheld devices that the baby dinosaurs are using on the cover, are just one of the cutting-edge applications you'll find in Silberschatz, Galvin, and Gagne's Operating System Concepts, Seventh Edition.

By staying current, remaining relevant, and adapting to emerging course needs, this market-leading text has continued to define the operating systems course. This Seventh Edition not only presents the latest and most relevant systems, it also digs deeper to uncover those fundamental concepts that have remained constant throughout the evolution of today's operation systems. With this strong conceptual foundation in place, students can more easily understand the details related to specific systems.
New Adaptations
* Increased coverage of user perspective in Chapter 1.
* Increased coverage of OS design throughout.
* A new chapter on real-time and embedded systems (Chapter 19).
* A new chapter on multimedia (Chapter 20).
* Additional coverage of security and protection.
* Additional coverage of distributed programming.
* New exercises at the end of each chapter.
* New programming exercises and projects at the end of each chapter.
* New student-focused pedagogy and a new two-color design to enhance the learning process.

                                     CLICK HERE TO DOWNLOAD

                                     CLICK HERE TO DOWNLOAD

                                     CLICK HERE TO DOWNLOAD

* After Opening Press Ctrl + S (or) Go to File --> Download


Tags : Operating System - Silberschatz - Seventh edition ebook download , Operating System - Silberschatz - Seventh edition pdf , Operating System - Silberschatz - Seventh edition ebook pdf , Operating System - Silberschatz - Seventh edition .

DBMS - Ramez Elmasri - 6th edition



2010-04-09 | ISBN: 0136086209 | 1200 pages | PDF | 8,29 MB


Clear explanations of theory and design, broad coverage of models and real systems, and an up-to-date introduction to modern database technologies result in a leading introduction to database systems. Intended for computer science majors, Fundamentals of Database Systems, 6/e emphasizes math models, design issues, relational algebra, and relational calculus.

A lab manual and problems give students opportunities to practice the fundamentals of design and implementation. Real-world examples serve as engaging, practical illustrations of database concepts. The Sixth Edition maintains its coverage of the most popular database topics, including SQL, security, and data mining, and features increased emphasis on XML and semi-structured data.

��Fundamentals of Database Systems is a leading example of a database text that approaches the subject from the technical, rather than the business perspective. It offers instructors more than enough material to choose from as they seek to balance coverage of theoretical with practical material, design with programming, application concerns with implementation issues, and items of historical interest with a view of cutting edge topics.
CHenry A. Etlinger, Rochester Institute of Technology

This is an outstanding, up-to-date database book, appropriate for both undergraduate and graduate courses. It contains good examples, and clearly describes how to design good, operable databases as well as retrieve and manipulate data from an existing database.

                                     CLICK HERE TO DOWNLOAD

                                     CLICK HERE TO DOWNLOAD

                                     CLICK HERE TO DOWNLOAD

* After Opening Press Ctrl + S (or) Go to File --> Download


Tags : DBMS - Ramez Elmasri  - 6th edition , DBMS ebook download , DBMS pdf download ,DBMS best book , DBMS - Ramez Elmasri  - 6th edition download ,DBMS - Ramez Elmasri  - 6th edition pdf , DBMS - Ramez Elmasri  - 6th edition ebook download , free ebook websites , free it ebooks , free dbms ebooks , DBMS - Ramez Elmasri  - 6th edition

Computer Networks - Tanenbaum 5th edition



                         *** Redirected to another Page... ***