Thursday, June 28, 2012

RunLevel in Linux

There are differences in the runlevels according to the operating system. seven runlevels are supported in the standard Linux kernel
The Runlevels in System  describe certains states :: For Example

a) Runlevel 0 : Halt(No activity, the system can be safely powered down)
b) Runlevel 1 : Single user mode(raerly used )
c) RL 2 : Multiple users , no NFS(network filesystem),also used rarely.
d) RL 3 : Multiple users, command line (i.e all text mode ) interface the standard runlevel for most linux based server hardware.
e) RL 4 : User define
f) RL 5 : Multiple users, GUI ; the standared runlevel for most linux based desktop system.
g) Renlevel 6 : Reboot


Linux change Run level command :

who -r // It give the current runlevel

init 1  //It is used for to change the runlevels.


Monday, June 25, 2012

Create RPM Files

 STEPS FOR CREATING THE RPM FILES:::

A) first we have to create the five file in any directory i.e::::
mkdir -p BUILD  RPMS  SOURCES  SPECS  SRPMS

B) create your binary file of any program like i created one program of hello world!! and then compile it then it become the binary file.
copy that binary file into that path  SOURCE->rpmdemo-0.1 ->bin

then make the tar file of the rpmdemo-0.1.tar.gz.

Then make the spec file and past it into the SPECS folder .

Some changes in the spec file are : change the name of rpm of your output(binary of the hello world.).

then compile it by that command :::

rpmbuild -v -bb --clean SPECS/rpmdemo.spec --define "_topdir${PWD}"


----------------------------------------------------------------------------------------------------------
Only .tar.gz, .tar, .tgz and .tar.Z can be used with RPM.


************************************************************************
 Some useful links::
http://home.gna.org/subtitleeditor/

Friday, June 15, 2012

FREAD AND FWRITE function

IT IS MAINLY USED FOR READING AND WRITING THE DATASTRUCTURE:


FREAD and FWRITE:

#include <stdio.h>
size_t fread(vid *ptr, size_t size, size_t nmemb, FILE *stream);
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE * stream);

The ffread () reads nmemb elements of data , each size bytes long,from the stream pointed to by stream, stroring them at the location given by ptr.


The Function fwrite () writes nmemb element of data, each size bytes long to stream pointed to by stream ,obtaining them from the location given by ptr.

Code for creating the cscope.out file

cscope package is used for the searching in the whole project.

For making the file we have to ::


    find . -name '*.[ch]' > cscope.files //It include the .c file and .h file both
 
cscope -b
    CSCOPE_DB=cscope.out; export CSCOPE_DB

thats it for that we have to alredy install the cscope package in the system.
 
commands ::

** uname- It is used for the get all the information of the system like the versoin , processor, releasel, O.S,Node,etc.

ex: uname -a : it will give all the information of the system.
    uname -v,r,n,s,o etc..
  
 
 
-----------------------------------------------------------------
                      links Imp
1.http://principialabs.com/beginning-ssh-on-ubuntu/ (for the ssh login remotly)

MEMSET function and MEMCPY function and FLUSH function

MEMSET - It fill the memory with a constant byte
#include <string.h>
void *memset (void *s , int c , size_t n);

The memset () function fills the first n bytes of the memory area pointed to by s with the constant byte c.

--It return a pinter to the memory area s.
------------------------------------------------------------------------------------------------------------
MEMCPY-- copy memory area

#include <string.h>
void *memcpy( void *dest, const void *src , size_t n);

The memcpy() function copies n bytes from memory area src to memory area dest. the memory areas shoul not overlap. Use memmove if memory areas do overlap.
***************************************************************************
SYNC-- flush file system buffers
sync();

Force changed blocks to disk, update the super block.

******************************************************************************
FFLUSH-- flush a stream

#include <stdio.h>
int fflush (FILE *stream );

Description: It forces a write of all user-space buffered data for the given output or update stream via the stream's underlying write function.
 

Tuesday, June 5, 2012

Signal in Unix

The signal API function allows us to install a signal handler for a process.
the prototype of signal api function is defined as :

sighandler_t signal (int  signum, sighandler_t handler);
where signalhandler_t typedef is :
typedef void (*sighandler_t)(int);

signal handlers for a process can be of three different types. they can be ignored (via SIG_ING), the default handler for the particular signal type (SIG_DEF) or a user defined handler (install via signal).

* The first group (terminate Ex. SIGHUP, SIGINT) lists the signal whose default action is to terminate the process. The second group (ignore EX. SIGCHLD, SIGCLD) list the signals for which the default action is to ignore the signal. The third group (core EX. SIGQUIT, SIGILL) list those signal whose action is to both terminate the process and perform a core dump (generate a core dump file) . and finally the fourth group (stop SIGABRT, SIGIOT, SIGBUS) stop the process (suspend , rather than terminate).

Wait in Unix

The purpose of the wait API function is to suspend the calling process until the child process exits or until a signal is delivered.
If the parent isn't currently waiting on the child to exit, the child exit , and the child process becomes a zombie process.

The prototype for the wait function is defined as :

pid_t wait(int *status)

The status variable returns status information about the child exit. This variable can be evaluated using a number of macros. Like :

1. WIFEXITED: Non zero if the child exited normally.
2.WEFSIGNALED : Return true if child exited due to a signal that wasn't caught by the child.
3. WTERMSIG : Return the signal number that caused the child to exit.
4.WEXITSTATUS : Return the exit status of the child .

Monday, June 4, 2012

Fork In Unix

The fork API function provides the means to create a new child subprocess form the existing parent process. some difference include is process id of parent and the child is different.

** File locks and signals that are pending to the parent are not inherited by the child process.

The prototype for the fork() function is :

pid_t fork(void);

** The fork call has a very unique structure in that the return value identifies the context in which the process is running . if the return value is Zero, then the current process is the newly created child process. If the return value is greater than Zero then the current process is Parent.


** EAGAIN AND ENOMEM: Both the errors arise from a lack of available memory.

** Rather than copy the page tables for the memory when the fork takes place, the parent and child share the same page tables but are not permitted to write to them . When a write takes place to one of the shared page tables, the page table is copied for the writing process so that it has its own copy. This is called the "copy- on - write".
Only as writes occur to the share data memory does the segregation(The action or state of setting someone or something apart from other people or things or being set apart)  of the page tables take place.

Qualcomm Short Term

  113 is the SL. 1st Target by mid July.

Total Pageviews