<?xml version="1.0" encoding="iso-8859-2"?>
<rss version="2.0">
<channel>
<title>Prtogramowanie c/ C++</title>
<link>http://www.programowanie.pun.pl</link>
<description> Prtogramowanie c/ C++</description>
<language>pl</language>
<docs>http://backend.userland.com/rss</docs>
<item>
<title></title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=16#p16</link>
<guid isPermaLink="false">16@http://www.programowanie.pun.pl</guid>
<description><![CDATA[Paczka znajduje się pod adresem:<br /><a href="http://www.fipomat.ugu.pl/kody/threads2/Zal.zip" target="_blank" rel="nofollow">www.fipomat.ugu.pl/kody/threads2/Zal.zip</a><br />Powodzenia żołnierzu:D<br /><br /><br /><br /><br /><br /><a href="http://www.fipomat.ugu.pl/kody/threads2/Zal2.zip" target="_blank" rel="nofollow">www.fipomat.ugu.pl/kody/threads2/Zal2.zip</a>]]></description>
<pubDate>PiĹˇtek 27 StyczeĹ„</pubDate>
<comments>PiĹˇtek 27 StyczeĹ„</comments>
</item>
<item>
<title>source</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=15#p15</link>
<guid isPermaLink="false">15@http://www.programowanie.pun.pl</guid>
<description><![CDATA[#include &lt;iostream&gt;<br />#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &lt;pthread.h&gt; // zainkludowanie biblioteki<br />#include &lt;queue&gt;<br /><br />using namespace std;<br /><br />// dwa watki - jeden odczytuje z pliku tekstowego znak po znaku<br />// drugi wyswietla odczytane dane na ekranie<br />// oba watki dzialaja do momentu odczytania i wyswietlenia calego pliku<br />// watek wyswietlajacy dane powiniene wyswietlac je co 100 ms<br /><br />#define SIGNS_TO_READ = 5;<br /><br />pthread_t reader;<br />pthread_t writer;<br /><br />int finishRead = 1;<br />int finishWrite = 1;<br /><br />pthread_mutex_t finishCreatedMutex;<br />pthread_cond_t finishTreshold;<br /><br />pthread_mutex_t fifoMutex;<br /><br />queue&lt;char&gt; fifo;<br /><br />FILE *fp;<br /><br />void openFile() {<br />&nbsp; &nbsp; /* używamy metody wysokopoziomowej - musimy mieć zatem identyfikator pliku, uwaga na gwiazdkę! */<br />&nbsp; &nbsp; if ((fp = fopen(&quot;czytaj.txt&quot;, &quot;r&quot;)) == NULL) {<br />&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Nie mogę otworzyć pliku czytaj.txt do odczytu!\n&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />&nbsp; &nbsp; } else {<br />&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Otworzono plik&quot;);<br />&nbsp; &nbsp; }<br />}<br /><br />void waitingMutex() {<br />&nbsp; &nbsp; pthread_cond_wait(&finishTreshold, &finishCreatedMutex);<br />}<br /><br />void sendSignal() {<br />&nbsp; &nbsp; pthread_cond_signal(&finishTreshold);<br />}<br /><br />void *read(void* data) {<br />&nbsp; &nbsp; char ch;<br />&nbsp; &nbsp; while (1) {<br />&nbsp; &nbsp; &nbsp; &nbsp; int count = 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; while (count &lt; 2) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch = fgetc(fp);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pthread_mutex_lock(&fifoMutex);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ch != EOF)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fifo.push(ch);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pthread_mutex_unlock(&fifoMutex);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; waitingMutex();<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; if (ch == EOF) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Zamkniecie pliku\n&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fclose(fp);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; printf(&quot;Zakonczenie 1 watku\n&quot;);<br />&nbsp; &nbsp; finishRead = 0;<br />&nbsp; &nbsp; pthread_exit(NULL);<br />}<br />void *write(void* data) {<br />&nbsp; &nbsp; printf(&quot;Watek 2 rozpoczyna dzialanie\n&quot;);<br />&nbsp; &nbsp; char z;<br />&nbsp; &nbsp; while (finishRead) {<br />&nbsp; &nbsp; &nbsp; &nbsp; usleep(100000);<br />&nbsp; &nbsp; &nbsp; &nbsp; pthread_mutex_lock(&fifoMutex);<br />&nbsp; &nbsp; &nbsp; &nbsp; while (fifo.size() != 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = fifo.front();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fifo.pop();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; z &lt;&lt; endl;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; pthread_mutex_unlock(&fifoMutex);<br />&nbsp; &nbsp; &nbsp; &nbsp; sendSignal();<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; printf(&quot;Zakonczenie 2 watku&quot;);<br />&nbsp; &nbsp; pthread_exit(NULL);<br />}<br /><br />void createThreads() {<br /><br />&nbsp; &nbsp; pthread_mutex_init(&finishCreatedMutex, NULL);<br /><br />&nbsp; &nbsp; printf(&quot;\nCreate thread\n&quot;);<br />&nbsp; &nbsp; int rc;<br />&nbsp; &nbsp; rc = pthread_create(&reader, NULL, read, NULL);<br />&nbsp; &nbsp; if (rc) {<br />&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;ERROR; return code from pthread_create() is %d\n&quot;, rc);<br />&nbsp; &nbsp; &nbsp; &nbsp; exit(-1);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; usleep(100000);<br />&nbsp; &nbsp; printf(&quot;\nDrugi\n&quot;);<br />&nbsp; &nbsp; rc = pthread_create(&writer, NULL, write, NULL);<br />&nbsp; &nbsp; if (rc) {<br />&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;ERROR; return code from pthread_create() is %d\n&quot;, rc);<br />&nbsp; &nbsp; &nbsp; &nbsp; exit(-1);<br />&nbsp; &nbsp; }<br />}<br /><br />void joinThread() {<br />&nbsp; &nbsp; pthread_join(reader, NULL);<br />&nbsp; &nbsp; pthread_join(writer, NULL);<br />}<br /><br />int main(void) {<br />&nbsp; &nbsp; printf(&quot;Program start\n&quot;);<br />&nbsp; &nbsp; openFile();<br />&nbsp; &nbsp; createThreads();<br />&nbsp; &nbsp; joinThread();<br />&nbsp; &nbsp; return 0;<br />}]]></description>
<pubDate>PiĹˇtek 27 StyczeĹ„</pubDate>
<comments>PiĹˇtek 27 StyczeĹ„</comments>
</item>
<item>
<title>kompilacja linux</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=14#p14</link>
<guid isPermaLink="false">14@http://www.programowanie.pun.pl</guid>
<description><![CDATA[Mozna to troche zautomatyzowac:<br /><br />1. Odplamy konsole przechodzimy do katalogu w ktorym mamy pliki zrodlowe projektu<br />2. Tworzymy sobie prosty sktypcik: <br />&nbsp; &nbsp;- poleceniem touch nazwapliku.rozszerzenie&nbsp; &nbsp;mozna bez rozrzerzenia albo .sh bedzie to konsolowe<br />3 Otwieramy skrypcik i wklejamy do niego to co ma robic np:<br /><br />rm wynik <br />g++ Main.cpp Consumer.cpp ConsumerKeyboard.cpp Product.cpp ProductType.cpp Manufacturer.cpp Order.cpp OrderList.cpp Mutex.cpp Utils.cpp&nbsp; -o wynik -lpthread <br />./wynik<br /><br />gdzie kolejno pierwsza linia usuwa nam skompilowany plik wynik<br />druga kompiluje nam wszystkie klasy ze zlinkowniem -lpthread i skompilowany program zapisuje w pliku wynik<br />trzecia natomiast odpala nam skompilowany program<br /><br />4. Wazne jest to zeby nadac uprawnienia do wykonania skryptu. W linuksie mozna to zrobic przez wpisanie w konsole polecenia:<br /> <br />chmod a+x&nbsp; ./nazwapliku.rozrzerzenie&nbsp; &nbsp; oczywiscie mowa o pliku ktory ma nam kompilowac<br /><br /><br />5. Ostatnim krokiem jest odpalanie naszego skryptu przez : ./nazwapliku.rozszerzenie&nbsp; &nbsp; Skrypt automatycznie nam zrobic clear projektu skompiluje zliknkuje i odpali program wynikowy. Jesli odpowiedz byla przydatna daj plusa:)]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>kompilacja linux</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=13#p13</link>
<guid isPermaLink="false">13@http://www.programowanie.pun.pl</guid>
<description><![CDATA[jak kompilować pod linuxem.<br />&nbsp; gcc dla czystego C<br />&nbsp; g++ dla c++<br /> <div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 4.5em"><pre> gcc main.cpp(pliki wejsciowe) -o prog(definiujemy plik wyjsciowy) -lpthread(dolacz biblioteki -l o nazwie thread)</pre></div></div></div>mozna sobie wygenerować makefile neo.dmcs.pl/tk/makehtml]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>pliki</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=12#p12</link>
<guid isPermaLink="false">12@http://www.programowanie.pun.pl</guid>
<description><![CDATA[mmx/sse2<br /><br /><a href="http://infobot.pl/r/234F" target="_blank" rel="nofollow">http://infobot.pl/r/234F</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Img8Operations.cpp<br /><br /><br />thread<br /><br /><br /><a href="http://infobot.pl/r/234G" target="_blank" rel="nofollow">http://infobot.pl/r/234G</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Kolejka.cpp<br /><a href="http://infobot.pl/r/234H" target="_blank" rel="nofollow">http://infobot.pl/r/234H</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Kolejka.h<br /><a href="http://infobot.pl/r/234I" target="_blank" rel="nofollow">http://infobot.pl/r/234I</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ProducentKlient.cpp<br /><br />OpenMP<br /><br /><br /><a href="http://infobot.pl/r/234J" target="_blank" rel="nofollow">http://infobot.pl/r/234J</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vector.cpp<br /><a href="http://infobot.pl/r/234K" target="_blank" rel="nofollow">http://infobot.pl/r/234K</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vector.h<br /><a href="http://infobot.pl/r/234L" target="_blank" rel="nofollow">http://infobot.pl/r/234L</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;main.cpp<br /><br /><br />Inne<br /><br /><a href="http://strony.toya.net.pl/~a_bo/" target="_blank" rel="nofollow">http://strony.toya.net.pl/~a_bo/</a>]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>Linki</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=11#p11</link>
<guid isPermaLink="false">11@http://www.programowanie.pun.pl</guid>
<description><![CDATA[Wykład&nbsp; &nbsp;<a href="http://neo.dmcs.pl/num/wyklad.pdf" target="_blank" rel="nofollow">http://neo.dmcs.pl/num/wyklad.pdf</a><br /><br />informacje o w±tkach : <a href="https://computing.llnl.gov/tutorials/pthreads/#Mu" target="_blank" rel="nofollow">https://computing.llnl.gov/tutorials/pthreads/#Mu</a>]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>tworzenie watkow podstawowe</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=10#p10</link>
<guid isPermaLink="false">10@http://www.programowanie.pun.pl</guid>
<description><![CDATA[przykłady pochodz± ze strony <a href="https://computing.llnl.gov/tutorials/pthreads/#Mu" target="_blank" rel="nofollow">https://computing.llnl.gov/tutorials/pthreads/#Mu</a><br /><br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 35em"><pre>#include &lt;pthread.h&gt;
#include &lt;stdio.h&gt;
#define NUM_THREADS     5

void *PrintHello(void *threadid)
{
   long tid;
   tid = (long)threadid;
   printf(&quot;Hello World! It's me, thread #%ld!\n&quot;, tid);
   pthread_exit(NULL);
}

int main (int argc, char *argv[])
{
   pthread_t threads[NUM_THREADS];
   int rc;
   long t;
   for(t=0; t&lt;NUM_THREADS; t++){
      printf(&quot;In main: creating thread %ld\n&quot;, t);
      rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
      if (rc){
         printf(&quot;ERROR; return code from pthread_create() is %d\n&quot;, rc);
         exit(-1);
      }
   }

   /* Last thing that main() should do */
   pthread_exit(NULL);
}</pre></div></div></div>bardziej rozbudowany przykład :D<br /><br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 35em"><pre>#include &lt;iostream&gt;
#include &quot;Kolejka.h&quot;
#include &lt;pthread.h&gt;
#include &lt;stdio.h&gt;
#include &lt;ctime&gt;
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;stdlib.h&gt;
using namespace std;

#define KLIENT_NUMBER         7
#define MAX_COUNT             15


int ZamowienieID=1;
int count=0;
int flaga=0;

pthread_mutex_t Signal_Mutex;
pthread_attr_t attr;
pthread_cond_t count_treshold_cv;


void *KlientKeyboardTask(void *threadid)
 {
       long NumerWatku;
       NumerWatku = (long)threadid;
       int TypeOfProduct=-1;
   for(;;)
       {

       std::cout&lt;&lt;&quot;\n\n\nWybierz produkt dla zamowienia klienta &quot;&lt;&lt;NumerWatku&lt;&lt;&quot;\n&quot;;

       while(TypeOfProduct == -1)
           {
           std::cin&gt;&gt;TypeOfProduct;
           usleep(10);
           }

           std::cout&lt;&lt;&quot;\n\n\Klient o ID: &quot;&lt;&lt;NumerWatku&lt;&lt;&quot;probuje zlozyc zamowienie\n\n\n&quot;;

           Kolejka::GetKolejka()-&gt;wstaw_na_kon(NumerWatku,TypeOfProduct,&ZamowienieID);

                   pthread_mutex_lock(&Signal_Mutex);
                   pthread_cond_wait(&count_treshold_cv,&Signal_Mutex);
                   Kolejka::GetKolejka()-&gt;usun_pierwszy();
                   cout&lt;&lt;&quot;\n\n\t\t\t\t\t\t\t\t\t&quot;&lt;&lt;NumerWatku&lt;&lt;&quot; odebral swoje zamowienie\n\n&quot;;
                   TypeOfProduct=-1;
                   pthread_mutex_unlock(&Signal_Mutex);
       }
pthread_exit(NULL);
 }

void *ProducentTask(void *threadid)
{
   sleep(2);
   for(;;)
           {
           //std::cout&lt;&lt;&quot;working&quot;;
           while(Kolejka::GetKolejka()-&gt;pierwszy-&gt;produkt[4]==0 && Kolejka::GetKolejka()-&gt;pierwszy-&gt;produkt[5]==0)
             {
                  pthread_mutex_lock(&Signal_Mutex);

                          int NumerZamowienia = Kolejka::GetKolejka()-&gt;pobierz_pierwszy(1);
                          int NumerKlienta = Kolejka::GetKolejka()-&gt;pobierz_pierwszy(2);
                          int RodzajTowaru = Kolejka::GetKolejka()-&gt;pobierz_pierwszy(3);
                          pthread_mutex_unlock(&Signal_Mutex);
                          std::cout&lt;&lt;&quot;\t\t\t\t\t\t\t\t\tProducent rozpoczyna realizacje za2mowienia ID: &quot;&lt;&lt;NumerZamowienia&lt;&lt;&quot;\n\t\t\t\t\t\t\t\t\tZamowienie klienta: &quot;&lt;&lt;NumerKlienta&lt;&lt;&quot; na towar: &quot;&lt;&lt;RodzajTowaru&lt;&lt;&quot;\n&quot;;
                          int CountLimit;
                          switch(RodzajTowaru)
                                  {
                                         case 0: std::cout&lt;&lt;&quot;\t\t\t\t\t\t\t\t\tWykonanie produktu zajmie okolo 300min\n&quot;;CountLimit=2;break;

                                  }
                          Kolejka::GetKolejka()-&gt;pierwszy-&gt;produkt[4]=1;

                          pthread_cond_signal(&count_treshold_cv);
                          sleep(CountLimit);
             }

           }
   pthread_exit(NULL);

}
int main (int argc, char *argv[])
{
   pthread_t Klient[KLIENT_NUMBER];
   pthread_t Producent;
   pthread_t KlientKeyboard;
   pthread_mutex_init(&Signal_Mutex, NULL);
   pthread_cond_init(&count_treshold_cv,NULL);
   pthread_attr_init(&attr);


   int rc;
   int rd;
   int re;


   for(long t=1; t&lt;=KLIENT_NUMBER-1; t++)
       {
       //sleep(2);
       rc = pthread_create(&Klient[t],&attr, KlientTask, (void *)t);
       std::cout&lt;&lt;&quot;Klient &quot;&lt;&lt;t&lt;&lt;&quot; gotowy do dzialania\n&quot;;
       if (rc!=NULL)
                {
                std::cout&lt;&lt;&quot;Bład podczas tworzenia klienta&quot;&lt;&lt;t&lt;&lt;&quot;funkcja zwraca wartosc&quot;&lt;&lt;rc;
                }
       }
   rd=pthread_create(&Producent, &attr, ProducentTask, (void *)int(KLIENT_NUMBER+1));
   if (rd!=NULL)
               {
               std::cout&lt;&lt;&quot;Bład podczas tworzenia producenta funkcja zwraca wartosc&quot;&lt;&lt;rd;
               }
   re=pthread_create(&KlientKeyboard, &attr, KlientKeyboardTask, (void *)KLIENT_NUMBER);
   if (re!=NULL)
                {
                std::cout&lt;&lt;&quot;Bład podczas tworzenia klienta z obsluga klawiatury funkcja zwraca wartosc&quot;&lt;&lt;re;
                }

   pthread_join(Producent,NULL);

   pthread_exit(NULL);
}</pre></div></div></div>]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>FiFo alokowane dynamicznie</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=9#p9</link>
<guid isPermaLink="false">9@http://www.programowanie.pun.pl</guid>
<description><![CDATA[#include &quot;Kolejka.h&quot;<br /><br />#include &lt;iostream&gt;<br />#include&nbsp; &lt;stdio.h&gt;<br />#include &lt;cstdlib&gt;<br />#include &lt;ctime&gt;<br /><br />Kolejka Kolejka::kolejka;<br /><br /><br />Kolejka::Kolejka()<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pierwszy =ostatni = NULL;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ile = 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br /><br />Kolejka::~Kolejka()<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dane *temp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(pierwszy) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = pierwszy;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pierwszy = pierwszy-&gt;nastepny;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delete temp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />}<br /><br />void Kolejka::wstaw_na_kon(int klient, int WybranyProdukt, int *ZamowienieID)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dane *nowy = new dane;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(ile&lt;=4)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(ile)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ostatni-&gt;nastepny = nowy;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;produkt[1] = *ZamowienieID;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout&lt;&lt;&quot;Wygenerowano zamowienie numer:&quot;&lt;&lt;nowy-&gt;produkt[1];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;produkt[2]= klient;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout&lt;&lt;&quot; przez klienta: &quot;&lt;&lt;nowy-&gt;produkt[2];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;produkt[3]= WybranyProdukt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout&lt;&lt;&quot; na produkt: &quot;&lt;&lt;nowy-&gt;produkt[3]&lt;&lt;&quot;\n&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;nastepny = NULL;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;produkt[4]=0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;produkt[5]=0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ostatni = nowy;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ile++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*ZamowienieID)++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Kolejka::sprawdzanie=1;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pierwszy = ostatni = nowy;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;produkt[1] = *ZamowienieID;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout&lt;&lt;&quot;Wygenerowano zamowienie numer:&quot;&lt;&lt;nowy-&gt;produkt[1];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;produkt[2]=klient;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout&lt;&lt;&quot; przez klienta: &quot;&lt;&lt;nowy-&gt;produkt[2];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;produkt[3]=WybranyProdukt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout&lt;&lt;&quot; na produkt: &quot;&lt;&lt;nowy-&gt;produkt[3]&lt;&lt;&quot;\n&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;nastepny = NULL;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nowy-&gt;produkt[4]=0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;nowy-&gt;produkt[5]=0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ile++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*ZamowienieID)++;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Kolejka::sprawdzanie=1;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />void Kolejka::usun_pierwszy()<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dane *pom;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pom = pierwszy;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pierwszy = pierwszy-&gt;nastepny;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delete pom;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ile-=1;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br /><br />int Kolejka::pobierz_pierwszy(int liczba)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dane *pom;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pom = pierwszy;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return pom-&gt;produkt[liczba];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />void Kolejka::wypisz()<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dane *pom;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pom = pierwszy;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (pom)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout &lt;&lt;&quot;ID zamowienia: &quot;&lt;&lt; pom-&gt;produkt[1]&lt;&lt;&quot;, zlozone przez klienta: &quot;&lt;&lt;pom-&gt;produkt[2]&lt;&lt;&quot; na produkt: &quot;&lt;&lt;pom-&gt;produkt[3]&lt;&lt; &quot;\n&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pom = pom-&gt;nastepny;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>SSE2</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=8#p8</link>
<guid isPermaLink="false">8@http://www.programowanie.pun.pl</guid>
<description><![CDATA[dodawanie <br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 13.5em"><pre>__int64 c = b;
__m128i nChange128 = Get_m128(c,c);
                        {
                            vektor4 = _mm_loadu_si128((__m128i*)&pSource[counter]);
                            _mm_store_si128((__m128i*)&pDest[counter], _mm_adds_epu8(vektor4,nChange128));
                                
                        }</pre></div></div></div>odejmowanie<br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 13.5em"><pre>__int64 c = b;
__m128i nChange128 = Get_m128(c,c);
                        {
                            vektor4 = _mm_loadu_si128((__m128i*)&pSource[counter]);
                            _mm_store_si128((__m128i*)&pDest[counter], _mm_subs_epu8(vektor4,nChange128));
                                
                        }</pre></div></div></div>porównywanie wartosci<br /><br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 9em"><pre>        {
            vektor1 = _mm_loadu_si128((__m128i*)&pSource[i]);
            _mm_store_si128((__m128i*)&pDest[i],_mm_cmpeq_epi8(_mm_subs_epu8(threshold128,vektor1), zero128));
        }</pre></div></div></div>wartosc bezwzgledna<br /><br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 33em"><pre>    __m128i *vektor1;
    __m128i *vektor2;
    __m128i *vektor3;
    __m128i *vektor4;
    __m128i *vektor5;

    __m128i abs1;
    __m128i abs2;

            vektor1 = (__m128i*)&pSource[counter];
            vektor2 = (__m128i*)&pSource[counter+1+nWidth];
            vektor3 = (__m128i*)&pSource[counter+1];
            vektor4 = (__m128i*)&pSource[counter+nWidth];
            vektor5 = (__m128i*)&pDest[counter];

            abs1 = _mm_or_si128(_mm_subs_epu8(_mm_loadu_si128(vektor1),_mm_loadu_si128(vektor2)), _mm_subs_epu8(_mm_loadu_si128(vektor2),_mm_loadu_si128(vektor1)));
            abs2 = _mm_or_si128(_mm_subs_epu8(_mm_loadu_si128(vektor3),_mm_loadu_si128(vektor4)), _mm_subs_epu8(_mm_loadu_si128(vektor4),_mm_loadu_si128(vektor3)));
            
            _mm_store_si128(vektor5,_mm_adds_epu8(abs1, abs2));
        }</pre></div></div></div>]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>MMX</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=7#p7</link>
<guid isPermaLink="false">7@http://www.programowanie.pun.pl</guid>
<description><![CDATA[uzupelnianie <div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 4.5em"><pre>_mm_set1_pi8</pre></div></div></div>dodawanie:<br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 16.5em"><pre>__m64* vektor1;
__m64* vektor2;
                  for(int counter=0; counter&lt;nNumberOfPixels; counter+=8)
                        {
                            vektor1 = (__m64*)&pSource[counter];
                            vektor2 = (__m64*)&pDest[counter];
                            *vektor2 =_mm_adds_pu8(*vektor1,nChange64);    
                        }
                  _mm_empty();</pre></div></div></div>odejmowanie<br /><br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 13.5em"><pre>__m64* vektor1;
__m64* vektor2;
                        {
                            vektor1 = (__m64*)&pSource[counter];
                            vektor2 = (__m64*)&pDest[counter];
                            *vektor2 =_mm_subs_pu8(*vektor1,nChange64);    
                        }</pre></div></div></div>porownywanie wartosci<br /><br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 16.5em"><pre>__m64* vektor1;
__m64* vektor2;

        {
            vektor1 = (__m64*)&pSource[counter];
            vektor2 = (__m64*)&pDest[counter];
            *vektor2 = _mm_cmpeq_pi8(_mm_subs_pu8(threshold64,*vektor1), zero64);
        }
        _mm_empty();</pre></div></div></div>liczenie wartosci bezwzglednej<br /><br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 21em"><pre>            vektor1 = (__m64*)&pSource[counter];
            vektor2 = (__m64*)&pSource[counter+1+nWidth];
            vektor3 = (__m64*)&pSource[counter+1];
            vektor4 = (__m64*)&pSource[counter+nWidth];
            vektor5 = (__m64*)&pDest[counter];

            abs1 = _mm_or_si64(_mm_subs_pu8(*vektor1,*vektor2), _mm_subs_pu8(*vektor2,*vektor1));
            abs2 = _mm_or_si64(_mm_subs_pu8(*vektor3,*vektor4), _mm_subs_pu8(*vektor4,*vektor3));

            *vektor5 = _mm_adds_pu8(abs1, abs2);
        }
        _mm_empty();</pre></div></div></div>]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>main</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=6#p6</link>
<guid isPermaLink="false">6@http://www.programowanie.pun.pl</guid>
<description><![CDATA[<div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 15em"><pre>Vector MyVector1(Capacity);    

start = clock();
MyVector1.AddVector(MyVector2);
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;

cout&lt;&lt;&quot;\n\nCzas dodawania wektorow bez uzycia instrukcji wynosi            : &quot;&lt;&lt;duration&lt;&lt;&quot;s\n&quot;;</pre></div></div></div>]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>sprawdzanie czy procesor wspiera instrukcje</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=5#p5</link>
<guid isPermaLink="false">5@http://www.programowanie.pun.pl</guid>
<description><![CDATA[TO bardzo interesujace rozwiazanie. Mozna to jednak zrealizowac w troche inny sposob. Jak chwile pomysle to wrzuce udoskonalona wersje]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>sprawdzanie czy procesor wspiera instrukcje</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=4#p4</link>
<guid isPermaLink="false">4@http://www.programowanie.pun.pl</guid>
<description><![CDATA[sprawdzanie czy procesor obsluguje instrukcje poszczegolne:<br /><br />CheckSupportedInstructions();<br /><br /><div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 35em"><pre>void CheckSupportedInstructions()
             {
                int CPUInfo[4] = {-1};    
                __cpuid(CPUInfo, 1);

                if(CPUInfo[3] & ((int)1&lt;&lt;23))
                    {
                     cout&lt;&lt;&quot;Procesor obsluguje instrukcje :        MMX\n&quot;;
                    }
                
                if(CPUInfo[3] & ((int)1&lt;&lt;25))
                    {
                     cout&lt;&lt;&quot;Procesor obsluguje instrukcje :        SSE\n&quot;;
                    }
                if(CPUInfo[3] & ((int)1&lt;&lt;26))
                    {
                     cout&lt;&lt;&quot;Procesor obsluguje instrukcje :        SSE2\n&quot;;
                    }
                if(CPUInfo[2] & ((int)1&lt;&lt;9))
                    {
                     cout&lt;&lt;&quot;Procesor obsluguje instrukcje :        SSE3\n&quot;;
                    }
                if(CPUInfo[2] & ((int)1&lt;&lt;19))
                    {
                    cout&lt;&lt;&quot;Procesor obsluguje instrukcje :        SSE4\n&quot;;
                    }
             }</pre></div></div></div>]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>struktura vector.cpp</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=3#p3</link>
<guid isPermaLink="false">3@http://www.programowanie.pun.pl</guid>
<description><![CDATA[<div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 35em"><pre>Vector::Vector(int ArraySize)
                 {
                   this-&gt;Size = 0;
                   this-&gt;Capacity = ArraySize;
                   this-&gt;VectorArray = new unsigned char[this-&gt;Capacity];
                 }

void Vector::PutSignIntoArray(unsigned char Sign)
                {
                    if(this-&gt;Size &lt; this-&gt;Capacity)
                        {
                        this-&gt;VectorArray[this-&gt;Size]= Sign;
                        this-&gt;Size++;
                        //cout &lt;&lt; &quot;Dodano Element :&quot; &lt;&lt; Sign&lt;&lt; &quot;\n&quot;;
                        }
                    else
                        {
                            int NewCapacity=this-&gt;Size+5;
                            Vector MyVector3(NewCapacity);

                            for(int counter = 0; counter &lt;= this-&gt;Size; counter++)
                                {
                                    if(counter == this-&gt;Size)
                                        {
                                            MyVector3.VectorArray[counter] = Sign;
                                            MyVector3.Size++;
                                        }                                    
                                    else
                                        {
                                            MyVector3.VectorArray[counter] = this-&gt;ReadArrayAt(counter);
                                            MyVector3.Size++;
                                        }
                                }
                            
                            cout &lt;&lt; &quot;\nDodano Element (zostala rozszerzona tablica)\n\n&quot;;
                            delete[] this-&gt;VectorArray;
                            this-&gt;VectorArray = new unsigned char[NewCapacity];
                            this-&gt;Capacity = NewCapacity;
                            this-&gt;Size = 0;

                            for(int counter2 = 0; counter2 &lt; MyVector3.Size; counter2++)
                                {
                                    this-&gt;VectorArray[counter2]=MyVector3.ReadArrayAt(counter2);
                                    this-&gt;Size++;
                                }
                            
                        
                        }
                }


void Vector::AddVectorMMX(Vector VectorToAdd)
                        {
                        
                                        __m64* vektor1;
                                        __m64* vektor2;

                                if(this-&gt;Size &gt;= VectorToAdd.Size)
                                    {
                                        for(int counter = 0; counter&lt; this-&gt;Size; counter+=8)
                                            {
                                                vektor1 = (__m64*)&this-&gt;VectorArray[counter];
                                                vektor2 = (__m64*)&VectorToAdd.VectorArray[counter];
                                                *vektor1 = _mm_adds_pu8(*vektor1,*vektor2);    
                                            }
                                      _mm_empty();
                                    }
             }

void    Vector::AddVectorSSE(Vector VectorToAdd)
                        {
                            __m128i vektor4;
                            __m128i vektor5;
                            
                            if(this-&gt;Size &gt;= VectorToAdd.Size)
                                    {
                                     for(int counter=0; counter &lt; this-&gt;Size; counter+=16)
                                            {
                                                vektor4 = _mm_loadu_si128((__m128i*)&this-&gt;VectorArray[counter]);
                                                vektor5 = _mm_loadu_si128((__m128i*)&VectorToAdd.VectorArray[counter]);
                                                _mm_storeu_si128((__m128i*)&this-&gt;VectorArray[counter], _mm_add_epi8(vektor5, vektor4));
                                            }
                                    }
              }</pre></div></div></div>]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
<item>
<title>struktura 1 pliku vector.h</title>
<link>http://www.programowanie.pun.pl/viewtopic.php?pid=2#p2</link>
<guid isPermaLink="false">2@http://www.programowanie.pun.pl</guid>
<description><![CDATA[<div class="codebox"><div class="incqbox"><h4>Kod:</h4><div class="scrollbox" style="height: 35em"><pre>class Vector 
{
    public:
    //constructors
            Vector();
            Vector(int size);
            Vector(const Vector& VectorCopy);
            Vector& operator=(Vector& VectorCopy2);
            ~Vector();
    //methods
            int                GetArraySize();
            int                GetArrayCapacity();
            int                Capacity;
            int                Size;
            void            PutSignIntoArray(unsigned char Sign);
            void            AddVector(Vector VectorToAdd);
            void            AddVectorMMX(Vector VectorToAdd);
            void            AddVectorSSE(Vector VectorToAdd);
            void            FillArray(unsigned char Sign);
            unsigned char   ReadArrayAt(int Position);
            
    private:
            unsigned char *VectorArray; 


};</pre></div></div></div>]]></description>
<pubDate>Wtorek 3 StyczeĹ„</pubDate>
<comments>Wtorek 3 StyczeĹ„</comments>
</item>
</channel>
</rss>
