Saturday, November 21, 2020

Difference between softirq, tasklet, workqueue and threaded_irq

 While Linux interrupt handling, To perform "bottom half",  There are couple of methods used as below.

  • Tasklet

    • It can not sleep.
    • It run in software interrupt context
    • These are atomic. These are guaranteed to never run on more than one CPU of a given processor, for a given tasklet. In other terms they do not run concurrent, (If you have multiple different tasklet in single driver then they can run concurrent)
    • They may be scheduled to run multiple times, but tasklet scheduling is not cumulative; the tasklet runs only once, even if it is requested repeatedly before it is launched
    • However, another interrupt can certainly be delivered while the tasklet is running, so locking between the tasklet and the interrupt handler may still be required
    • Tasklets can be statically allocated using DECLARE_TASKLET(name, func, data) or can also be allocated dynamically and initialized at runtime using tasklet_init(name, func, data)
    • Tasklets are actually run from a softirq

Saturday, October 3, 2020

Different type of operators and type casting in C programming

  •  Airthmetic Operations
                + , - , *, / , %
  • Relation Operations
                <. <=, >, >=, ==, !=
  • Logical Operations
                && logical AND
                ||   logical OR
                !    logical NOT
  • Assignment operations
                a = a+ 1  is called a += 1

Data Types and storage class in C programming

 ANSI C support different 3 types of data types.

  1. Primary data types
    • int, (short,long,signed,unsigned) 
    • char, (signed,unsigned)
    • float,  (float,double,long double)
    • void 
  2. Derived data types
    • arrays
    • strings
    • structures
  3. User-Defined data type
    • typedef 
      • typedef <old name> <new name>;
    • enum identiifers
      • enum day [monday, tuesday, ... sunday];

Basic information about C programming

 C Tokens

Just like any other programming C programming has 6 different tokens
  1. Keywords (there are 32 keywords in C89, lile int,flot)
  2. Identifiers (main)
  3. Constants
  4. Strings
  5. Special symbols
  6. Operators

Constant has further few more types.

1) Integer constants

C program compilation flow

 Here is the brief summary of detail C program compilation process.


Source File (.c file)

            |

Preprocessing (Include all header file code in main source code, Expand all Macro and #define) (.i file)

            |

Compilation (Convert the program into assembly code) (.s file)

            |

Assembling (Convert the assembly code into machine code called object) (.obj or .o file)

            |

Linking  (Links different object file/module and system library together and create final executable object code) (.exe or .out file)       


History of C programming

  • ALGOL (The root of all mordern programming language)  #1960
  • BCPL (Basic combined programming language)  #1967
  • B (It was used to create early version of UNIX in Bell Lab) #1970
  • Traditional C  #1972
  • K&R C  launched book #1978. C started some acceptence
  • C89 / ANSI C (Americal National Standard Institute) launched in #1989 also known as C89
  • C90 (ANSI & ISO commite approved) #1990
Meanwhile Sun Microsystem launched JAVA based on C & C++

In 1999, Standardization commite, decided to keep adding new feature of C++/Java in C and they launched

  • C99  in #1999
  • C11 in  #2011
  • C18 in  #2018
  • C2X in progress

Most famous compilers like gcc, LLVM clang, IAR, Microsoft Visual C++ VS 2019 support all this standars. (Atleast for x86 platform) 

Friday, July 3, 2020

Inter Process Communication method in linux

There are 5 different IPC methods in Linux


  1. Shared memory.  (Related process)
  2. Memory mapped.   (Unrelated process)
  3. Pipe (Related process)
  4. FIFO (Unrelated process)
  5. Socket (Unrelated process in two different system)
Related processes means, parent-child kind of relation. processes created by fork,vfork kind of system call.