Missing You Shayari

Missing You Shayari

Yaadon Me Hamari Aap Bhi Khoye Honge,
Khuli Aankho Se Kabhi Aap Bhi Soye Honge,
Maana Hasna Hai Ada Gam Chhupane Ki,
Par Haste Haste Kabhi Aap Bhi Roye Honge….

Category: Uncategorized | Comments Off on Missing You Shayari

using pthread_mutex_timedlock in linux.

We saw in the post ” ” how we can use mutexes in pthreads to achieve synchronization among various threads. Along with the the three functions we saw, there is a fourth mutex function that we can use when we want to wait on a mutex for only a specific duration and then continue irrespective of whether we are able to get a lock on the mutex or not. The function for timed operation on mutex it pthread_mutex_timedlock whose syntax is

int pthread_mutex_timedlock(pthread_mutex_t *restrict mutex,const struct timespec *restrict abs_timeout);

The timeout is the time for which we want to wait on the mutex. To specify the timeout we need to use the structure timepsec which has two fields one for seconds and other for nanoseconds as shown below.

struct timespec { __time_t tv_sec; /* Seconds. */ long int tv_nsec; /* Nanoseconds. */ };

The mutex if available will be locked immediately, if the mutex is not available the thread will wait for the duration of time mentioned in the abs_timeout and then exit from the wait.

The following program shows an example of using the pthread_mutex_timedlock. In the program thread1 takes a value as input from the user and assigns it to a variable “temp”. In thread2 the same variable is accessed and its value is printed. Thread1 locks a mutex while getting the value for temp from the user, but thread2 waits only for 5 seconds for the mutex to get unlocked after which it exits with a time out message and does not print the value of the variable temp.

To mention the timeout we need to first allocate memory for a timespec structure

struct timespec *wait wait=(struct timespec *)(malloc(sizeof(struct timespec)); wait->tv_sec=5; wait->tv_nsec=0;

Thus now we have a timespec structure with 5 seconds and 0 nanoseconds as the time values, which can be passed to the function pthread_mutex_timedlock to achieve a 5 second timeout.
The whole function looks as follows

#include#include#include#include pthread_mutex_t mutex1,mutex2; #define perror(s) printf(“\n” s “\n”); int temp; void * func1(){ pthread_mutex_lock(&mutex1); printf(“\nEnter a value for temp\n”); scanf(“%d”,&temp); pthread_mutex_unlock(&mutex1); } void * func2() { struct timespec *wait; int ret; wait=(struct timespec *)(malloc(sizeof(struct timespec))); wait->tv_sec=5; wait->tv_nsec=0; sleep(5); ret=pthread_mutex_timedlock(&mutex1,wait); if(ret!=0){ perror(“Wait timed out”); return ; } printf(“\nvalue assigned for temp is %d\n”,temp); pthread_mutex_unlock(&mutex1); } main() { int ret; pthread_t thread1,thread2; ret=pthread_create(&thread1,NULL,&func1,NULL); if(ret!=0){ perror(“Unable to create thread”); } ret=pthread_create(&thread2,NULL,&func2,NULL); if(ret!=0){ perror(“Unable to create thread”); } printf(“Created threads”); pthread_join(thread1,NULL); pthread_join(thread2,NULL); }

Save the program as mutex_timedlock.c, and compile it with the flag -lpthread

$ cc -lpthread -o mutex_timedloc mutex_timedlock.c

While executing the program when the prompt for entering a value for the variable appears, if you wait for more than 5 seonds for entering the value, you will noticed the timed out message from the second thread will appear on the other hand if we enter the value with in 5 seconds the value entered is printed by the second thread. case1: Waiting for more than 5 seconds before entering the value

$ ./mutex_timedlock Created threads Enter a value for temp Wait timed out 5

Created threads Enter a value for temp 5 value assigned for temp is 5

Thus we are able to achieve a mutex lock for a specific duration using the pthread_mutex_timedlock function.

Category: Linux | Comments Off on using pthread_mutex_timedlock in linux.

Shayari on Dosti

Dosti Shayari

Kyu Mushkilon Me Saath Dete Hain Dost,
Kyun Gam Ko Baant Lete Hain Dost,
Na Rishta Khoon Se Na Riwaaz Se Bandha,
Fir Bhi Zindagi Bhar Saath Dete Hain Dost…

Category: Uncategorized | Comments Off on Shayari on Dosti

Shayari on Mohabbat

Dard Shayari

Mohabbat Har Insaan Ko Aazmati Hai,
Kisi Se Rooth Jaati Hai Par Kisi Pe Muskurati Hai,
Mohabbat Khel Hi Aisa Hai,
Kisi Ka kuch nahi Jaata Kisi Ka Sab Kuch Chala Jaata Hai…

Category: Uncategorized | Comments Off on Shayari on Mohabbat

Heart Touching Love Shayari

Love Shayari

Dil Ko Hum Se Churaya AapNe,
Door Hote HuA Apna Banaya AapNe,
Kabhi Bhool Nahi Payenge Aap Ko,
Kyu Ki Yaad Rakhana Sikhaya AapNe….

Category: Uncategorized | Comments Off on Heart Touching Love Shayari

Shayari on Love in Hindi

Romantic Shayari

Pyaar Me Milna Jaruri Nahi,
Pyaar Mein Izhaar Bhi Zaruri Nahi,
Zaruri Sirf Ehsaas Hai Jo Zindagi SaNwarde,
Unhe PaAna Ya Na Pana Zaruri Nhi…

Category: Uncategorized | Comments Off on Shayari on Love in Hindi

Shayari on Love in Hindi

Romantic Shayari

Pyaar Me Milna Jaruri Nahi,
Pyaar Mein Izhaar Bhi Zaruri Nahi,
Zaruri Sirf Ehsaas Hai Jo Zindagi SaNwarde,
Unhe PaAna Ya Na Pana Zaruri Nhi…

Category: Uncategorized | Comments Off on Shayari on Love in Hindi

Romantic Love Shayari in Hindi

Love Shayari for Facebook

Ishq Aisa Karo Ki Dhadkan Me Bas Jaaye,
Saans Bhi Lo To Khushbu Usi Ki Aaye,
Pyaar Ka Nasha Aankhon Pe Chaa Jaaye,
Baat Kuch Bhi Na Ho Par Naam Usi Ka Aaye…

Category: Uncategorized | Comments Off on Romantic Love Shayari in Hindi

Animated gif image of linux using gimp

Here are steps of how we can create the following animated linux gif image using gimp.

Note: This was created using gmip 2.6.10

Open gimp and go to

file->create->logos->cool_metal

This will show a menu as shown below.
In the field marked “text” , enter L, choose the font size that you would like and then click on the gradient to pick the color gradient you wish for the text.

The animation shown below uses the incandescent.

This will create a image as shown below.

Save the image as L.jpg. While saving remeber to take the file type as .jpg.

Following the same steps create the other images with the following text

LI LIN LINU LINUX

Now Open gimp again.

click on file->new->template

choose the size of the template you want, (Base it on the size of the font that you have created).

Now drag and drop the 4 jpg images that we created above in the order

L.jpg LI.jpg LIN.jpg LINU.jpg LINUX.pg

Download an image of tux, the penguin, from net if you want to and add that too to the gimp.

You should see all the six images in six layers as shown below.

Now to create an animation using these layers, click on save as and choose the image type to be .gif and add the extention to the name while saving as shown below

Before saving a window will appear, confirming whether you want to save as animation or just as an image, choose save as animation, and click on export

In the next window shown below, you can choose how much dealy should be given between every frame. The more delay you give the slower the animation will look. Check the loop for ever button to keep running the animation infinietly and click on save.

Now your gif animated image should be ready.

Category: Linux | Comments Off on Animated gif image of linux using gimp

Dard Bhari Shayari

Bewafa Shayari

Dil Ke Sagar Me Lehre Uthaya Na Karo,
Khwab Bankar Neend Churaya Na Karo,
Bahot Chot Lagti Hai Mere Dil Ko,
Tum Khwabo Mein Aa Kar Yu Tadpaya Na Karo….

Category: Uncategorized | Comments Off on Dard Bhari Shayari