Ad

Thursday, June 23, 2016

S290 - LINUX PROGRAMMING

S290 - LINUX PROGRAMMING

UNIT - I

Linux Utilities
UNIT - II

8_Shell Variables
       Shell Script Variables
       Shell Variables and Environment Variables
9 Command Substitution
10 shell Commands
11 12  Quoting and Environment Variables List
13  Test Command
17 Interrupt Processing (courtesy:Tutorials Point )
18 Functions
19 Debugging Shell Scripts

UNIT - III

1. File Concept
2. File System Structure
3. Inode
4. File Attributes
5. File types
6. Library Functions,Standard IO, Formatted IO and Stream Errors
10 kernel support for Files
11 System Calls
12 File Descriptors
13 Low level File access using System calls
14 File and Record Locking
15 File and Directory management
UNIT - IV
1.sed ppt
2.awk ppt
3. Built-in Functions ( courtesy : Tutorialspoint )
      Arithmetic Functions
      String Functions
      Time Functions
      Bit-Manipulation Functions
      Miscellaneous Functions
4.awk - Using System commands in awk
5. Socket Programming Theory
6. Connection Oriented programs

UNIT - V

1.Process Creation and Termination in Ubuntu
        Process Concept and process creation
        process structure_1
        process structure_2
        Process State_1
        Process state list in linux
        process state list in linux and PCB
        Process termination_1
        Process termination_2
    Note :-  Process Creation and Termination from wrox - our second textbook
2. Scheduling Algorithms in Ubuntu
3. Page replacement algorithms in linux ( technical paper - courtesy -www.ijera.com) 
4. InterProcess Communication 
5. MultiThreading in Ubuntu 
6. Ubuntu File System ( courtesy - Bhagyesh.S.Patel - SSBT's COET,Jalgoan)

Tuesday, December 1, 2015

Web Technologies ( Lecture NOtes )

Web Technologies

HTML


Cascading Style Sheets

JavaScript

JAVA BEANS

Monday, October 12, 2015

LFU Program

LFU Program

#include<stdio.h>
struct page
   {
      int pno;
      int counter;
    }pages[10];
void print(int a[],int n)
    {
     int i;
     for(i=0;i<n;i++)
  {
    printf(" %d ",a[i]);
   }
      printf("\n");
     }
int search(int e,int a[],int n)
    {
    int i;
      for(i=0;i<n;i++)
{
    if(e==a[i])
  {
return 1;
   }
}
    return 0;
    }
void initialize()
  {
   int i=0;
   for(i=0;i<10;i++)
       {
  pages[i].counter=0;
       }
  }
void main()
  {
    int prs[30],prss,nf,i,j,pno,mm[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
    int min_t=999,min_p,pf=0;
    clrscr();
printf("Enter MM size(no. of frames):");
scanf("%d",&nf);
printf("enter page ref. string size:");
scanf("%d",&prss);
printf("enter page ref string:");
for(i=0;i<prss;i++)
   {
scanf("%d",&prs[i]);
   }
initialize();//making all page counter=0
//LFU algo.
for(i=0;i<prss;i++)
    {
    pno=prs[i];
    pages[pno].counter++;//increment counter for referenced page
min_t=999;
if(search(prs[i],mm,nf)==0)//when referred page is not in mm
 {
for(j=0;j<nf;j++)//to get least counter page in MM
  {
   pno=mm[j];
    if(pages[pno].counter<min_t)
{
min_t=pages[pno].counter;
min_p=j;
}
   }
mm[min_p]=prs[i];
printf("--Page Fault--");
pf++;
}
print(mm,nf);
     }
    printf("\nNo. of Page Faults:%d",pf);
    getch();
   }

Output:

Wednesday, October 7, 2015

LRU Program


                                      LRU Program

#include<stdio.h>
struct page
   {
      int pno;
      int at;  
    }pages[10];
void print(int a[],int n)
    {
     int i;
     for(i=0;i<n;i++)
           {
             printf(" %d ",a[i]);
            }
      printf("\n");
     }
int search(int e,int a[],int n)
    {
    int i;
      for(i=0;i<n;i++)
        {
    if(e==a[i])
           {
        return 1;
            }
         }
    return 0;
    }
void main()
  {
    int prs[30],prss,nf,i,j,pno,mm[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
    int counter=0,min_t=999,min_p,pf=0;
        printf("Enter MM size(no. of frames):");
        scanf("%d",&nf);
        printf("enter page ref. string size:");
        scanf("%d",&prss);
        printf("enter page ref string:");
        for(i=0;i<prss;i++)
            {
        scanf("%d",&prs[i]);
            }
         //LRU algo.
         for(i=0;i<prss;i++)
             {
        counter++;//logical clock ticks for every page ref.
        pno=prs[i];
                pages[pno].at=counter;//storing time of page ref.
        min_t=999;
                if(search(prs[i],mm,nf)==0)
                  {
                for(j=0;j<nf;j++)
                   {
                    pno=mm[j];
                     if(pages[pno].at<min_t)
                        {
                min_t=pages[pno].at;
                min_p=j;
                         }
                    }
                mm[min_p]=prs[i];
                printf("--Page Fault--");
                pf++;
                 }
                print(mm,nf);
   
              }
    printf("\nNo. of Page Faults:%d",pf);  
   }
OutPut:-
 
 Enter MM size(no. of frames):3
enter page ref. string size:20
enter page ref string:7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
--Page Fault-- 7  -1  -1
--Page Fault-- 7  0  -1
--Page Fault-- 7  0  1
--Page Fault-- 2  0  1
 2  0  1
--Page Fault-- 2  0  3
 2  0  3
--Page Fault-- 4  0  3
--Page Fault-- 4  0  2
--Page Fault-- 4  3  2
--Page Fault-- 0  3  2
 0  3  2
 0  3  2
--Page Fault-- 1  3  2
 1  3  2
--Page Fault-- 1  0  2
 1  0  2
--Page Fault-- 1  0  7
 1  0  7
 1  0  7

No. of Page Faults:12

Wednesday, September 30, 2015

FIFO- Page Replacement Algorithms


Program for FIFO PAge Replacement Algorithm

#include<stdio.h>
#include<conio.h>
void print(int a[],int n)
   {
   int i;
   for(i=0;i<n;i++)
    {   printf(" %d ", a[i]);}
   printf("\n");
   }
int search(int e,int a[],int n)
   {
   int i;
   for(i=0;i<n;i++)
      {
      if(a[i]==e)
     {return i;}
      }
   return -1;
   }
int count(int a[],int n)
   {
   int count=0,i;
   for(i=0;i<n;i++)
      {
      if(a[i]!=-1){count++;}
      else{break;}
      }
   return count;
   }
void main()
   {
   int prs[30],mm[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},prss,nf,i,j,loc,c,fi;
   int pf=0;
   clrscr();
   printf("enter Main Memory Size(no. of frames):");
   scanf("%d",&nf);
   printf("enter page ref stream size:");
   scanf("%d",&prss);
   printf("enter page ref stream:");
   for(i=0;i<prss;i++)
      {
      scanf("%d",&prs[i]);
      }
   //FIFO algo.
   for(i=0,fi=0;i<prss;i++)
      {
       loc=search(prs[i],mm,nf);
       if(loc==-1)
     {
       printf("-Page fault-");
       pf++;
        if(i<nf){loc=i;}
        else
          {
          loc=fi;
          }
         mm[loc]=prs[i];
         if(fi<nf&&i>=nf){fi=loc+1;}
         if(fi==nf){fi=0;}
     }
      print(mm,nf);

      }
   printf("\nTotal No. of page faults:%d",pf);
   getch();
   }
OUTPUT

Friday, September 25, 2015

Main Memory - ppt link & paging doc

Main Memory

Download 
·        NO External Fragmentation
·        But Internal Fragmentation exists
o   Page size : 4 bytes
o   Program size : 25 bytes
o   No. of pages : 6 (24 bytes) + 1 ( 1byte)
o   Internal fragmentation : 4-1=3 bytes
·        Expected Fragmentation : On average, one half page per process
·        When Page size is small then overhead is more
·        Multiple page sizes
o   Ex:- Solaris
·        Research : variable on-the-fly page size
·        User program view s memory as one single space but, in fact, user program is scattered throughout physical memory.
·        Frame Table: Data structure, which frames are allocated, which frames are available and total no. of frames.


Hardware Support:
·        Most OS maintains a page table per process.
·        Pointer to page table is stored in process control block along with other register values.
·        Hardware Implementation of page table
o   Page Table is implemented as set of registers (problematic when page table is large)
o   Alternative, page table is kept in main memory and PTBR(Page Table Base Register) points to page table
§  Problem –2 memory accesses are needed to access a byte
§  memory access is slowed down by a factor of 2
o   Standard solution – TLB – Translation Look-aside Buffer
o   TLB is associative, high speed memory.
o   Each entry consists 2 parts:
§  Key or tag
§  Value

·        TLB HIT and TLB MISS
·        Associative memory – parallel search

          Address translation (p, d)
§  If p is in associative register, get frame # out
§  Otherwise get frame # from page table in memory
·        Some TLBs store address-space identifiers (ASIDs) in each TLB entry – uniquely identifies each process to provide address-space protection for that process
·        If the TLB does not support separate ASIDs, then every time a new page table is selected (for context switch), TLB must be flushed or erased.
·        HIT RATIO
o   Percentage of times that a particular page No. is found in the TLB
o   Example
§  Hit ratio=80%
·        TLB HIT
o   To search in TLB =20 nanoseconds
o   To access memory = 100 nanoseconds
o   Memory mapped access = 120 nanoseconds
·        For TLB MISS
o   To search = 20ns
o   To get page no. & frame no = 100 ns
o   To access = 100 ns
o   Total = 20+100+100=220ns
·        Effective Access Time = 0.80X120+0.20X220=140 ns
·        We suffer 40% slow down in memory access-time( from 100 to 140)
§  Hit ratio=98%
·        Effective Access Time = 0.98X120+0.20X220=122 ns
o   Increased hit rate produces only 22% slowdown in access time
Protection
·        In paging, memory is protected by protection bits associated with each frame.
·        Protection bits are kept in page table.
·        For every memory reference, during translation (L to P), protection bits can be checked to verify that no writes are being made to a read-only page.(if YES, trap)
·        Separate h/w can be provided for read-only, read-write or execute-only by providing separate protection bits for each kind of access.
·        In general -> one additional bit is attached to each entry in page table:
Valid – Invalid Bit
·        Invalid – the page is not in the process’s logical address space.
·        Example
o   14-bit address space => 0 to 16383
o   Program addresses => 0 to 10468
o   Page size = 2 KB
o   Any address reference to pages 6 or 7 is invalid and causes a trap.
o   According to program=> addr. After 10468 is invalid.
o   According to paging => addr. After 10468 to 12287 are valid … because page 5 ref. are valid and it is internal fragmentation.
·        Some systems provide h/w for page-table length register (PTLR) to indicate size of the page table. To check whether or not  the address is in the valid range for the process.


Shared Pages:

·        Advantage of paging: possibility of sharing code.
·        Mainly in time sharing systems
o   Example : 40 users using same program with re-entrant code=150KB & data=50KB
o   Total requirement : 8000 KB
o   Re-entrant code or pure code : never changes during execution time
·        In paging,
o   Code will be same for 40 users-150KB- same shared pages ed1,ed2,ed3
o   Data is different – 50 KB X 40 =>2000KB
o   Total : 2150KB (instead of 8000KB)
·        Note :- Heavily used programs like editor, compilers, run-time libraries, DB systems can be shared.