Tuesday, 29 August 2017

Linux Basics

UNIX : unix operating system was developed around 1960, at AT & T labs by dennis      ritch, after few years it made commerical

    ==>  then Richard stallmen decided to develop a new open source operating
        system, he is developer from MIT. he started a project GNU . which
        similar to whatever the facilites that offering by the UNIX os , they
       made all the required modules except the kernal,

 



LINUX  :   LInus Torvaldo , student form  elisinky university (finland) ,
          started a hobby of creating his own kernel version, In 25 Aug, 1991,
        he developed a terminal emulator (based on  Minix,it's just like unix
        terminal ,which used in universities for explanation purpose. ) he
         followed the architecture of the minix but he didn't used any code from      that) then  he posted a email in the minix user groups for feedback and
      suggesition, he annouced it's name as  "freax" => free, freak, x
      released 0.99 version of kernal , then some named it as LINUX kernal, then      Richard stallman used this kernal to complete his remaining project.
      then finally developed a free Open source Operating system under the
     (GPL) General Public License.... means anyone can use this freely ,
     and distribute to the other,modify also.


OS =>
        it's complicated/sophasticated a software ,
        which manages all the softwares and hardware resources.
   
    =>software which manages all the other resources...


Kernal ==>
           user space can't directly communicate with the hardware devices,
           only kernal have the privillage to communicate with the hardware
           components.
           we request the kernal with system calls..  kernal sends interrupts to           the hardware components to communicate .

       ==>  kernal is core of os.


shell==>

        ->   it is command interpretor
        ->   a software/program which acts as interface b/w the user and the
             kernel.


Library:=>
          It's binary file , a file which contains all the definitions of the
            functions , they are precompiled.
       
         => library files are created from the binary files.

            2 types of library files

     1)  Static :
                     extension:   libc.a


     2)  Dynamic :

                    extensions:     libc.so
                                  & libc.dll

  =>static linking:
                   
                      The address of the called function known to the main
     function at the time of compile time .this kind of linking is called
    static linking.

                    =>with static linking file size will be more becuase
                   it doesn't contain any seperate dll files so all files
                  are linked as a group so size of excutable file will be more.

                   => but one useful thing with static linking is ..executable                   files are portable (no dependency).

                 =>  statically linking will consume more memory. that's why
                 developers go for dynamic linking.

  =>Dynamic  linking:

                     The address of the called function known to the main
     function at the time of Run time .this kind of linking is called
    dynamic  linking.

                   => default linking is dynamic linking.

                   => in dynamic linking executable file size will be reduced


   ex:  printf is linked to the main function in dynamic linking.

=>   printf present in both  static libray & dynamic library
               
                   i)  libc.so
                   ii)  libc.a



==> Load time linking:
                      when executable file brought into memory for processing
                    at that time all the library files(a.out depends on)
                    are brought into memory



==> Run time linking :

                      link if necessary, otherwise don't link.


Commands: =>


$ cc -c 1.c    =>  compilation without linking

$ nm 1.o      =>  to know whether the fn defined or undefined

$ ldd a.out    =>  if it is dynamically linked then it
                   displays used shared library functions.

                    =>  list the libraries of a.out which depends on.

$ cc -static 1.o 2.o  =>  to link statically

$ file a.out   =>     to know whether it is dynamically linked or
                                            Statically  linked


**********   creation of library *********************************

ex:


        $ cc -c -fpic sum.c   (compilation without linking creates .o objective                                file)
        $ cc -c -fpic mul.c


        $ cc -shared -o libDynamic.so sum.o mul.o
     
        $ ar rcs libstatic.a  sum.o mul.o




  ********************    Process & Process management: **************

Process: =>
             application under execution is called process.


          ==> actually cpu excutes one process at a time.
         

       
Job concurrency/ Multi processing : =>


             => excuting multiple process at simultaneously/concurrently                         is called  multi processing.

             ==> this type of management is called cpu management.


cpu management =>

             =>  it's one of the resource manager.

             =>   execute all the process that are demanding the cpu in
                 efficient manner is called cpu management.

 efficient way means::
       
               ->  fair cpu sharing
               ->  response time
               ->  starvation       : demanding cpu but cpu not given
                                    :-> less starvation time is better
                                    -> we can minimize by Round dropping manner


               ->  throuput
               ->  turn around time : time gap b/w process loading and
                                      release(terminating).
               ->  wait time should be better



states of process::=>

           
   -> Ready/Runnable : the job needs nothing but cpu

   -> Delay/sleep    : in delay state it's not demand the cpu for the given
                       amount of delay time.

   -> suspended      : the job is interrupted from excution by interrupts, will
                       excute if resumed.

   -> wait/pending   :  the job is in waiting state
                     
                       -> the job is pending for i/o operations
                       -> event completion


***********   PCB (process control block) ************************


-> those many process/jobs, those many pcb's present

-> life of pcb  is equal to life of job.

->  cpu manager creates pcb's

-> when job is exited then pcb is released.

-> for each process there is unique process id present.

-> the switching of pcb is called   -> pcb switching
                                   
                                    -> process switching
                                   
                                    -> context switching



************************   bound ************************************

cpu bound ==>

             if a process in it's life time ,  if it present most of the time

            ready queue is called cpu bound.



i/o bound ==>
               if a process in it's life time, if it not demand cpu then

                it is called i/o bound.




->  for process manager  i/o bounds jobs are better....



************************************************************************


  prototypes  =>


1.         pid_t  fork(void);

2.         pid_t wait(int *status);

3.         pid_t waitpid(pid_t pid,int *status , int options);

4.         int  kill(pid_t pid,int sig_num);

5.        sighandler_t  signal(int signum, sighandler_t handler);

6.         int system(const char *command);

7.        int  getrlimit( int resource, struct rlimit *rlim);

8.         int setrlimit(int resource, const struct rlimit *rlim);

9.         int execl( const char *path, const char *arg,...);

10         int execlp(const char *path, const char *arg,...);

11     int execle(const char *path , const char *arg,... , char *const envp[]);

12        int  execv(const char *path , char *const argv[]);

13         int execvp(const char *file , char *const argv[]);

14    int  execve(const char *filename , char *const argv[],char *const envp[]);








No comments:

Post a Comment