Multithreading
This topic I was planning to study long time back,now got the time lets start….
Threads are often described as light-weight processes. They can work like two or more processes sharing the same address space ie they will work independently like processes but can share the same global variables.
Lets have some programming stuff in C
#include<stdio.h>
#include<pthread.h>
First we have to include the default threading library in Linux. pthread stands for POSIX threads. Include it to enable thread support for my program.
void* say_hello(void* data){
Each thread executes a function. In this case the function prototype is predefined. The function needs to have a void* pointer as argument and must return a void* pointer ( void* can be interpreted as a pointer to anything ).
char
*str;str = (char*)data;
The function converts the data pointer to a string pointer str and
while(1){ printf("%s\n",str);
runs a while loop to print it,
sleep(1);}}
the sleep function pauses the thread for 1 second as specified. Needless to say that the function never returns.
void
main(){ pthread_t t1,t2;
pthread_t is a data type that holds information about threads. Each thread requires one pthread_t variable
pthread_create(&t1,NULL,say_hello,"hello from 1");
The prototype used to create a thread include

thread is a pthread_t variable in our case t1 and t2. attr is a variable of type pthread_attr_t, if specified it holds details about the thread, like scheduling policy, stack size etc. Since we have specified NULL the thread runs with default parameters. start_routine is the function the thread executes. In our case it is the ever so friendly say_hello function. arg is a void pointer which points to any data type. This same pointer is passes to the start_routine function when it is called. In our case the strings hello from 1/hello from 2 are passed to the say_hello function in the data variable.
pthread_create(&t2,NULL,say_hello,"hello from 2");
pthread_join waits for the thread specifies in the first argument to exit, which in our case doesn’t happen, so the program runs forever, unless you interrupt it with Ctrl-C etc.The second argument is a pointer to the variable specified by pthread_exit in case the thread calls the function to exit. Since it is NULL, it is ignored.
pthread_join(t1,NULL);}
pthread_create() returns zero when the call completes successfully.If it return 11 it means EAGAIN ie The system lacked the necessary resources to create another thread, or the system-imposed limit on the total number of threads in a process PTHREAD_THREADS_MAX would be exceeded.
solution: 1) https://stackoverflow.com/questions/27237760/pthread-create-error-11-on-detached-threads
I tried this but it was not solved ,I need to know more
Raspberry pi -back up of my sd card — — https://thepihut.com/blogs/raspberry-pi-tutorials/17789160-backing-up-and-restoring-your-raspberry-pis-sd-card
socket
Socket is a way of speaking to other programs using standard file descriptors.After the socket() returns the socket descriptor, we start communicate through it using the specialized send()/recv() socket API calls.A TCP socket is an endpoint instance.A TCP socket is not a connection, it is the endpoint of a specific connection.A TCP connection is defined by two endpoints aka sockets.The purpose of ports is to differentiate multiple endpoints on a given network address.The port numbers are encoded in the transport protocol packet header, and they can be readily interpreted not only by the sending and receiving computers, but also by other components of the networking infrastructure. In particular, firewalls are commonly configured to differentiate between packets based on their source or destination port numbers as in port forwarding.