linux

Linux Basic Guide to Newbies

These instructions and examples focus on three popular distributions and their default graphical desktops: Fedora 14 using a GNOME desktop OpenSUSE 11.3 using a KDE 4 desktop Ubuntu 10.10 using a GNOME desktop Other distributions, desktops, and window managers are available, and we encourage you to explore further on your own. Even if some of […]

linux

What is Linux?

So, what is Linux, anyway? In the simplest terms, Linux is an operating system. It was created in October 1991 by a University of Helsinki student named Linus Torvalds (Linux stands for Linus’s UNIX). Linux itself is actually just the kernel; it implements multitasking and multiuser functionality, manages hardware, allocates memory, and enables applications to […]

Basic Unix Programming

Basic Unix Programming Signal Handler —————– /* Sample program to handle signals */ #include <signal.h>#include <stdio.h> void * myhandler(int myint){   printf(“nHey, I got signalled!!nn”);   exit(0);} int main(){   signal( SIGINT, (void *)  myhandler );    while(1) {    printf(“I am in an infinite loop!n”);    sleep(1);   }}     /* Skeletal Shell for simple command */ main (argc, […]

Basic Socket programming

Basic Socket programming /* Sample UDP client */   #include <sys/socket.h> #include <netinet/in.h> #include <stdio.h>   int main(int argc, char**argv) {    int sockfd,n;    struct sockaddr_in servaddr,cliaddr;    char sendline[1000];    char recvline[1000];      if (argc != 2)    {       printf(“usage:  udpcli <IP address>n”);       exit(1);    }      […]

Pthreads

PthreadsExample of multithreaded programming in C without mutual exclusion/locks #include <pthread.h> #include <stdio.h> int count = 0; void* run_thread() {    pthread_t thread_id = pthread_self();    printf(“Thread %u: Current value of count = %dn”, thread_id, count);    printf(“Thread %u incrementing count …n”);    count++;    sleep(1);    printf(“Value of count after incremented by thread %u […]

How to write the code for audio loopback in linux

How to write the code for  audio loopback in linux /* Standard Linux headers */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <signal.h> #include <getopt.h> #include <pthread.h> #include <errno.h>   #include <linux/soundcard.h>   #define FAILURE            -1 /* The number of channels of the audio codec */ #define NUM_CHANNELS           2   /* The […]

Packet decoder

Packet decoder #include <stdlib.h> // exit#include <unistd.h> // exit#include <arpa/inet.h> // inet_ntoa#include <netinet/if_ether.h> // ETHER_ADDR_LEN struct ip_header { // Internet Protocol header    #if BYTE_ORDER == LITTLE_ENDIAN    u_int ip_hl:4, ip_v:4;    #endif    #if BYTE_ORDER == BIG_ENDIAN    u_int ip_v:4, ip_hl:4;    #endif    u_char  ip_tos;            // type of service    u_short ip_len;            // total length     u_short ip_id;             // identification    […]

How to write the code for displaying mixer setting in linux

How to write the code for displaying mixer setting in linux /*  * mixer_info.c  * Example program to display mixer settings  */   #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <sys/ioctl.h> #include <fcntl.h> #include <linux/soundcard.h>   /* utility function for printing status */ void yes_no(int condition) {   condition ? printf(”  yes      “) : printf(”  […]

How to write configure script

1.Introduction To start using the GNU configure and build system with your software package, you must write three files, and you must run some tools to manually generate additional files. 2.Write configure.in   You must first write the file `configure.in’. This is an autoconf input file, and the autoconf manual describes in detail what this […]

How to write the code for audio loopback in linux

Programming /dev/dsp (Obsolute,But latest oss still support the old versions) /dev/dsp is the digital sampling and digital recording device, and probably the most important for multimedia applications. Writing to the device accesses the D/A converter to produce sound. Reading the device activates the A/D converter for sound recording and analysis. The name DSP comes from […]