Sunday, April 30, 2017

Posted by beni April 30, 2017
4.4px;"">Namun karena si D"7,lagu,dunia,yang,menjadi,miste...
Posted by beni in , | April 30, 2017
560 Servir560 ServirPara salvar o arquivo mp3 clique com o bot�o direito do mouse sobre o t�tulo da postagem e salve o arquivo. Os v�deos podem ser encontrados em www.3minutos.net Acompanhe no iTun...
Posted by beni in , , , , , | April 30, 2017
9 Kisah Persahabatan Sejati Antar HewanExfile4shared.blogspot.com, Agar menjadi pribadi yang baik, adalah benar harus memilih sahabat yang membawa kita ke arah kebaikan. Pergaulan yang buruk pasti akan memberi pengaruh tidak baik pula bagi kita.Namun, memilih sahabat atas dasar warna kulit, suku, tingkat...
Posted by beni in , , , | April 30, 2017
551 Depois que morremos551 Depois que morremosPara salvar o arquivo mp3 clique com o bot�o direito do mouse sobre o t�tulo da postagem e salve o arquivo. Os v�deos podem ser encontrados em www.3minutos.net Acompanhe no iTun...
Posted by beni in , , , , , , , | April 30, 2017
5 Lukisan Telanjang yang Terkenal Termahal di Dunia Ini dia 5 lukisan bugil paling mahal di duniaDan ini bukan pornografi tapi melainkan karya artistik yang ditampilkan dengan cita rasa tinggi.5. NU COUCHE DE DOSLukisan ini dilukis pada tahun 1995 oleh Lucien Freud, dan dijual dengan harga $33.6 juta.4....
Posted by beni in , , , , , , | April 30, 2017
A Fitting Cue for Biosemi EEG CapUpon finishing measurement, if the size of a participants head falls on the border of the cap size reference, for example 56 cm of the red/blue (M-L).  It may be a better choice to go for a small cap.  That is to use the 54-58 cm red (M) cap, instead of using red/blue cap....
Posted by beni April 30, 2017

6 Pthread condition variable in Linux


Condition variable one type of thread synchronization mechanism.

By using condition variable we can tell one thread that when to execute.

using pthread_cond_signal pass the signal to another thread, this signal can be catch by another thread using pthread_cond_wait.


Below program
  • main thread will create two thread
  • second thread will wait on pthread_cond_wait to get signal.
  • first thread will increment the globalCount. When globalCount become 5 thread1 will send signal to thread2
  • now thread2 will get signal and add 20 to globalCount and exited from thread handler
  • then thread 1 increment the gloablCount until 15, and exited from thread handler function
PROGRAM : 
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
 
int globalCount = 0;
pthread_mutex_t mutex
;
pthread_cond_t condvar
;
 
void *t1_fun(void *arg) //thread 1 handler function
{
   
int i = 0;
   
int t_num = (int)arg;
 
   
for (i=0; i<15; i++) {
        pthread_mutex_lock
(&mutex);
        globalCount
++;
       
if (globalCount == 5) {
        pthread_cond_signal
(&condvar);
           
printf("t1_fun(): thread %d, globalCount = %d Signaled ", t_num, globalCount);
       
}
       
printf("t1_fun(): thread %d, globalCount = %d ", t_num, globalCount);
        pthread_mutex_unlock
(&mutex);
        sleep
(1);
   
}
    pthread_exit
(NULL);
}
 
void *condVar_fun(void *arg) //thread 2 handler function
{
int t_num = (int)arg;
       
   
printf("Thread %d created and running ", t_num);
    pthread_mutex_lock
(&mutex);
       
pthread_cond_wait
(&condvar, &mutex);
   
printf("condVar_fun(): Thread %d Condition signal received ", t_num);
    globalCount
+= 20;
printf("condVar_fun(): Thread %d globalCount = %d ", t_num, globalCount);
       
    pthread_mutex_unlock
(&mutex);
    pthread_exit
(NULL);
}
 
int main(int argc, char *argv[])
{
    pthread_t mythread1
;
    pthread_t mythread2
;
    pthread_attr_t myattr
;
   
void *joinResult;
   
int x = 0;
   
int t_arg = 1;
       
    pthread_attr_init
(&myattr);
    pthread_attr_setdetachstate
(&myattr, PTHREAD_CREATE_JOINABLE);
       
    pthread_mutex_init
(&mutex, NULL);
    pthread_cond_init
(&condvar, NULL);
       
   
if((pthread_create(&mythread1, &myattr, t1_fun,  (void*)t_arg) != 0)){
       
printf("Error, thread not created properly ");
       
return 1;
   
}
    t_arg
= 2;
   
if((pthread_create(&mythread2, &myattr, condVar_fun,  (void*)t_arg) != 0)){
       
printf("Error, thread not created properly ");
       
return 1;
   
}
   
    pthread_attr_destroy
(&myattr);
   
if(pthread_join(mythread1, &joinResult) != 0 ){
       
printf("Error pthread join ");
       
return 1;
   
}
   
printf("Main : Thread1 joined with result of %d ", (int)joinResult);
       
if
Posted by beni in , , , , , , , , , , | April 30, 2017
5 Kacamata Virtual Reality Terbaru dan Terbaik yang Harus Kamu CobaPesatnya perkembangan teknologi ternyata juga mempengaruhi dunia game. Saat ini, banyak perusahaan yang tengah mengembangkan berbagai teknologi virtual reality, salah satunya adalah perangkat berbentuk kacamatavirtual...
Posted by beni in , , , , , | April 30, 2017
A guide to install Ubuntu ServerThis installation of Ubuntu Server is performed on a PC with an optical drive, but you can alternatively use a USB flash drive too to boot into Ubuntu Server. The how-to to use a USB for installing any version of Linux is described step-by-step here.Prior to the boot...
Posted by beni in | April 30, 2017
ningtho...
Posted by beni in , , , , | April 30, 2017
570 Uns tirados outros deixados570 Uns tirados, outros deixadosPara salvar o arquivo mp3 clique com o bot�o direito do mouse sobre o t�tulo da postagem e salve o arquivo. Os v�deos podem ser encontrados em www.3minutos.net Acompanhe no iTun...
Posted by beni in , , , , | April 30, 2017
A Day That You ForgetSeorang kepala pelayan berseragam rapi dengan jas hitam dan kemeja putihnya, Alfred, bertanya kepada tuannya, �Apa Anda yakin hanya akan pergi berempat saja, Tuan Ryuki?��Tentu saja, Alfred,� jawab ayah dari dua orang anak dan suami dari seorang istri keluarga bangsawan itu. �Kau...

Search