<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Developpement on Blog GoHugo de Fredô : Linux, Proxmox, IA, Trail, Course, Randonnée, Gravel, Ski de Randonnée</title>
    <link>https://move.cyber-neurones.org/tags/developpement/</link>
    <description>Recent content in Developpement on Blog GoHugo de Fredô : Linux, Proxmox, IA, Trail, Course, Randonnée, Gravel, Ski de Randonnée</description>
    <generator>Hugo</generator>
    <language>fr</language>
    <lastBuildDate>Wed, 17 Oct 2018 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://move.cyber-neurones.org/tags/developpement/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Développement en C sous Linux : pthread et la fonction sleep().</title>
      <link>https://move.cyber-neurones.org/post/2018/10/2018-10-17-developpement-en-c-sous-linux-pthread-et-la-fonction-sleep/</link>
      <pubDate>Wed, 17 Oct 2018 00:00:00 +0000</pubDate>
      <guid>https://move.cyber-neurones.org/post/2018/10/2018-10-17-developpement-en-c-sous-linux-pthread-et-la-fonction-sleep/</guid>
      <description>&lt;p&gt;Un petit exemple vaut mieux que de grands discours, voici le &lt;strong&gt;source en C&lt;/strong&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;#include &#xA;#include &#xA;#include &#xA;#include &amp;lt;sys/time.h&amp;gt;&#xA;#include &amp;lt;sys/types.h&amp;gt;&#xA;#include &#xA;static long debut = 0;&#xA;void* longue_pause(void* a){&#xA;        pid_t t = getpid();&#xA;        printf(&amp;#34;pid = %d\n&amp;#34;,(int)t);&#xA;        printf(&amp;#34;thread longue_pause %d debut : %ld\n&amp;#34;,(int)pthread_self(),time(0)-debut);&#xA;        sleep(10);&#xA;        printf(&amp;#34;thread longue_pause %d fin : %ld\n&amp;#34;,(int)pthread_self(),time(0)-debut);&#xA;}&#xA;void* petites_pauses(void* a){&#xA;&#x9;int i = 0;&#xA;        pid_t t = getpid();&#xA;        printf(&amp;#34;pid = %d\n&amp;#34;,t);&#xA;        printf(&amp;#34;thread petites_pauses %d debut : %ld \n&amp;#34;,(int)pthread_self(), time(0)-debut);&#xA;        for(; i &amp;lt; 10 ;++i){&#xA;                printf(&amp;#34;thread petites_pauses %d en cours : %ld \n&amp;#34;,(int)pthread_self(), time(0)-debut);&#xA;                sleep(1);&#xA;        }&#xA;}&#xA;int main(){&#xA;        pthread_t longue;&#xA;        pthread_t petit1;&#xA;        pthread_t petit2;&#xA;        debut = time(0);&#xA;        pthread_create(&amp;amp;longue,NULL,longue_pause,NULL);&#xA;        pthread_create(&amp;amp;petit1,NULL,petites_pauses,NULL);&#xA;        pthread_create(&amp;amp;petit2,NULL,petites_pauses,NULL);&#xA;&#x9;sleep(8);&#xA;&#x9;printf(&amp;#34;Debut join: %ld\n&amp;#34;,time(0)-debut);&#xA;        pthread_join(longue,NULL);&#xA;        printf(&amp;#34;fin long : %ld\n&amp;#34;,time(0)-debut); &#xA;        pthread_join(petit1,NULL);&#xA;&#x9;printf(&amp;#34;fin petit1 : %ld\n&amp;#34;,time(0)-debut);&#x9;&#xA;        pthread_join(petit2,NULL);&#xA;&#x9;printf(&amp;#34;fin petit2 : %ld\n&amp;#34;,time(0)-debut);&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Pour la compilation :&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
