Skip to main content


Showing posts from August, 2009

PyTorch Code for Simple Neural Networks for MNIST Dataset

Square Wave Generation using Delay in 8051

To create a square wave generation using Delay. let us say we want to construct a 1khz square waveform the processor instruction cycle of 8051 is 1.085microseconds so for 1khz (1milli seconds =1/1khz), is 1ms/1.085microseconds = 921.6 (this value is set to the for loop) #include <reg51.h> void delay() { for(i=0;i<922;i++) } void main() { P0=0xff; delay(); P0=0x00; delay(); }

Main Algorithms of a Linux Kernel

Signals Signals are one of the oldest facilities of Inter Process Communication. Signals are used to inform the processes about the events. signals will be sent via the following function (by the Kernel) int send_sig_info(int sig, struct siginfo *info, struct task_struct *); sig – refers the signal number info – refers the sender t – refers to the tasks (the kernel may send signals to many processes) Booting the System There are many bootloaders available for linux, the common ones being the LILO and the GRUB loader LILO – LInux LOader GRUB – GRand unified Bootloader The steps while booting the kernel (only relevant steps are given) Entry point at start which is available at arch/x86/boot/setup.S (This is responsible for initializing the hardware (assembler code) Once the hardware is initialized, the process is switched to protected mode by setting a bit word in the machine status word. Next the assembler instruction,       jmpi 0×10000

Kernel Data Structures

Task Structure The fundamental entity of any operating system is the task or a process. The task structure is defined in the linux/sched.h and it is the important data structure and following are some of its parameters. struct task_struct { volatile long state; //determines the current state of the process like unrunnable, runnable and stopped unsigned long flags; // various flags for accounting purpose like PF_STARTIN, PF_MEMALLOC unsigned long ptrace; // process is being monitored by other process. int sigpending; //define when the signals must be handed over to this process mm_segment_t addr_limit; struct exec_domain *exec_domain; //domain other than x86 long need_resched; //flag indicates that scheduling must be executed int lock_depth; //structure is protected before simulataneous access can take place long counter; //dynamic priority of a process long nice; //static priority of a process unsigned long policy; //scheduling poli

Introduction to Linux Kernel

The Linux or the unix kernel is just developed under the microkernel architecture… The Microkernel provides only the necessary minimum of functionality (inter process communication and the memory management) and can be accordingly be implemented in a small and compact form. Building on this microkernel, the remaining functions of the operating system are relocated to the autonomous processes communicating with the microkernel via a well defied interface. Generally, microkernel systems have been created whose performance can be improved by the monolithic systems.  Since linux provides slow i386 architecture, so linux is developed using the monolithic design.. the code size of linux mainly occupied by the device drivers and similars. on the other hand, the central routines of process and memory management are relatively small and easily understood, with 13000 lines of C code in each Thus LINUX is successfully tries to make use of the advantages of a microkernel architecture without givin

Kernel Directory Structure

In Linux the Kernel source is available under /usr/src/linux. Architecture dependent code is available in the following directory structure arch/alpha – for the DEC Alpha Architecture arch/x86 – for the Intel 32 bit Architecture arch/arm – for the ARM Architecture arch/ia64 – for the intel 64 bit architecture arch/m68k – for the 68000 architecture and compatible processors.  init/ directory contains all the functions needed to start the kernel.   kernel/ – central sections of the kernel. Most important system calls are implemented here.  arch/x86/mm or mm/ – takes care of memory management by requesting and releasing kernel memories.   fs/ is the virtual file system interface. Some important file systems are proc, ext2,ext3,. The proc file systems is used for system management.  drivers/ – every operating system requires drivers for its hardware components. These are held in this director

Characteristics of Linux

Linux is Multiuser - allows number of users to work with the system at the same time Multitasking - supports true preemptive multitasking. All processes independently of each other. Multiprocessing - from kernel Version2.0 onwards, linux supports multiprocessor architectures. Applications are distributed across several processors. Architecture Independent - runs almost on all platform that are able to process bits and bytes. examples like IBM s390, Sparc, ARM, etc Demand Load Executables - only those parts of a program actually required for execution are loaded into memory. Support POSIX1003.1 standard - Linux since version. onwards supports POSIX 1003.1, which defines a minimum interface to a Unix like operating system Memory protected Mode - uses the processor’s memory protection mechanisms to provent the process from accessing memory allocated to the system kernel or other processes. This is for the security of the system Shared Libraries - it is a c

8051 Program to handle the Ports

  Tool used: Keil Compiler for 8051 Microcontroller used: Intel 8051AH (with 32 I/O Pins, Two timers/counters, 5 interrupts with 2 priority levels) //Program to handle ports of 8051 #include <reg51.h> void main() { P0=0x50; P1=0x10; P0=P1+P0; } The Port0 holds the data of 50H and Port1 holds 10H, both added together and result is in Port0 as 0x60;