PROGRAMMATISMOS SUSTHMATOS Exetˆseic B' Periìdou PDF

Description
PROGRAMMATISMOS SUSTHMATOS Exetˆseic B' Periìdou (aþ) Kˆtw apì poiec proôpojèseic mporoôme na dhmiourg soume èna arqeðo/sklhrì sôndesmo s' èna arqeðo pou an kei se ˆllo idiokt th; 'Otan to kˆnoume

Please download to get full document.

View again

of 21
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information
Category:

Crosswords

Publish on:

Views: 2 | Pages: 21

Extension: PDF | Download: 0

Share
Transcript
PROGRAMMATISMOS SUSTHMATOS Exetˆseic B' Periìdou (aþ) Kˆtw apì poiec proôpojèseic mporoôme na dhmiourg soume èna arqeðo/sklhrì sôndesmo s' èna arqeðo pou an kei se ˆllo idiokt th; 'Otan to kˆnoume autì, to arqeðo/sklhrìc sôndesmoc pou dhmiourg same èqei san idiokt th emˆc, ton idiokt th tou arqikoô arqeðou, kai giatð; Pìte mporeð, an mporeð, o ˆlloc idiokt thc na sb sei to sklhrì sôndesmo pou dhmiourg same; An sb sei o ˆlloc idiokt thc to arqikì arqeðo, tìte sb nei autìmata kai o sklhrìc sôndesmoc pou dhmiourg same, ìqi, kai giatð; (bþ) 'Otan termatðsei mða diergasða, èqei th dunatìthta na epistrèyei ènan akèraio kwdikì exìdou sth diergasða pou thn dhmioôrghse, kai mìno s' aut n. To Ðdio akrib c isqôei kai gia ta n mata, dhlad ìtan termatðzei èna n ma, mporeð na epistrèyei ènan akèraio kwdikì exìdou sto n ma pou to dhmioôrghse, kai mìno s' autì. H mình diaforˆ eðnai ìti prèpei na epistrafeð o akèraioc autìc kwdikìc prosarmosmènoc se deðkth se void. EpÐshc, ìtan dhmiourgeðtai èna n ma, upˆrqei h dunatìthta na perˆsoume sth sunˆrthsh pou ja arqðsei na ekteleð to n ma mða parˆmetro. Autì ìmwc eðnai arketˆ perioristikì, giatð kˆpoiec forèc ja jèlame na perˆsoume sth sunˆrthsh perissìterec paramètrouc, opìte s' autèc tic peript seic h mình mac lôsh eðnai h qr sh exwterik n metablht n. Sqoliˆste ta prohgoômena se 20 grammèc to polô. 2. Grˆyte èna prìgramma gia to kèlufoc Bourne (èstw ìti onomˆzetai rmperc ) to opoðo na diabˆzei apì thn prokajorismènh eðsodo (stdin) grammèc keimènou kai tic opoðec na metafèrei sthn prokajorismènh èxodo (stdout), èqontac kˆnei tic ex c tropopoi seic. An se kˆpoia gramm thc eisìdou upˆrqei o qarakt rac %, sthn èxodo na metafèretai h gramm thc eisìdou, èqontac apaleðyei ì,ti upˆrqei sth gramm apì ton qarakt ra autì, sumperilambanomènou, mèqri to tèloc thc gramm c. An upˆrqoun perissìterec thc mðac emfanðseic tou % sth gramm, to prohgoômeno efarmìzetai gia thn pr th emfˆnis tou, dhlad den metafèretai sthn èxodo ìlo to tm ma thc gramm c apì aut thn pr th emfˆnish mèqri to tèloc thc. An kˆnontac aut th diagraf, autì pou apomènei sth gramm eðnai mìno kenoð qarakt rec, tìte na mhn metaferjeð kajìlou h gramm sthn èxodo. 'Omwc, an sthn eðsodo upˆrqoun kenèc grammèc, qwrðc %, autèc na metaferjoôn autoôsiec sthn èxodo, ìpwc ˆllwste ja prèpei na sumbaðnei kai gia opoiad pote gramm thc eisìdou den perièqei %. Plhroforiakˆ, o qarakt rac % qrhsimopoieðtai sta progrˆmmata thc gl ssac programmatismoô Prolog gia thn èndeixh ènarxhc sqolðwn mèqri to tèloc thc gramm c. Dhlad, to prìgramma rmperc ja mporeð na qrhsimopoihjeð san èna fðltro aposqoliasmoô programmˆtwn Prolog. MÐa endeiktik ektèlesh eðnai h ex c: cat prog.pl parent(jim, john). % This is a fact parent(john, helen). % And another fact % and one percent more % These are two rules grandparent(x,z) :- parent(x,y), parent(y,z). mult(x,y,z) :- Z is X * Y. % Define multiplication./rmperc prog.pl parent(jim, john). parent(john, helen). grandparent(x,z) :- parent(x,y), parent(y,z). mult(x,y,z) :- Z is X * Y. 3. An to ektelèsimo prìgramma pou prokôptei apì to prìgramma C sthn epìmenh selðda onomˆzetai ptt, d ste èna pijanì apotèlesma thc entol c ptt 2 3. Exhg ste epðshc, polô sunoptikˆ, poia eðnai h leitourgða tou progrˆmmatoc. #include stdlib.h #include pthread.h int m; void *f(void *argp) { pthread_t *thrs; int i, retcode, sum = 0, n = (int) argp; thrs = malloc(m * sizeof(pthread_t)); printf( %d %d\n , n, pthread_self()); if (n--) { for (i=0 ; i m ; i++) pthread_create(thrs+i, NULL, f, (void *) n); for (i=0 ; i m ; i++) { pthread_join(*(thrs+i), (void **) &retcode); sum += retcode; } pthread_exit((void *) sum); } pthread_exit((void *) pthread_self()); } main(int argc, char *argv[]) { pthread_t thr; int n, retcode; n = atoi(argv[1]); m = atoi(argv[2]); pthread_create(&thr, NULL, f, (void *) n); pthread_join(thr, (void **) &retcode); printf( %d\n , retcode); pthread_exit(null); } Poio ja eðnai to apotèlesma thc ektèleshc thc entol c ptt 3 5 wc -l ; Genikˆ, ti ja perimènate na ektup netai apì thn entol ptt n m wc -l, gia opoiad pote n kai m, kai giatð; 4. Grˆyte èna prìgramma C (upojèste ìti onomˆzetai countfiles ) to opoðo ìtan kaleðtai me èna pl joc apì kìmbouc (katalìgouc, arqeða ˆllou eðdouc kìmbouc) tou ierarqikoô sust matoc arqeðwn sth gramm entol c, na metrˆ, gia kajèna ap' autoôc touc kìmbouc, pìsoi kìmboi upˆrqoun kˆtw ap' autìn, sumperilambanomènou kai tou Ðdiou, kaj c kai sunolikˆ. An to prìgramma klhjeð qwrðc orðsmata, na metrˆ touc kìmbouc kˆtw apì ton trèqonta katˆlogo. Fusikˆ, kˆtw apì èna kìmbo pou den eðnai katˆlogoc upˆrqei akrib c ènac kìmboc, o eautìc tou, en kˆtw apì èna katˆlogo pou perièqei dôo arqeða kai èna katˆlogo, o opoðoc perièqei trða arqeða, upˆrqoun eptˆ kìmboi. Gia parˆdeigma:./countfiles ~syspro/2005 ~syspro/sp_programs.. 11 file(s) under /home/users/syspro/ file(s) under /home/users/syspro/sp_programs 3919 file(s) under file(s) found in total./countfiles 20 file(s) found in total./countfiles ~syspro/sp_programs/* countfiles* 83 file(s) under /home/users/syspro/sp_programs/c_progs 7 file(s) under /home/users/syspro/sp_programs/sh_scripts 1 file(s) under countfiles 1 file(s) under countfiles.c 92 file(s) found in total PROGRAMMATISMOS SUSTHMATOS Exetˆseic A' Periìdou (aþ) Parathr ste thn parakˆtw dialogik epikoinwnða me to kèlufoc kai sumplhr ste entolèc a- potelèsmata entol n, ìpou upˆrqoun aposiwphtikˆ, ètsi ste h eikìna pou ja dhmiourg sete na eðnai sunep c. Se peript seic mhnumˆtwn lˆjouc apì entolèc, den zhteðtai h epakrib c diatôpws touc, apl c h ousða touc. MporeÐte na sumperˆnete, apì ta dedomèna pou èqete, pìsoi upokatˆlogoi perièqontai ston katˆlogo../syspro/dir2; Aitiolog ste tic apant seic sac. whoami billy ls -ld../syspro/dir? drwxr--r-- 2 syspro users 512 Sep 8 12:38../syspro/dir1 drwx--x--x 4 syspro users 512 Sep 8 12:44../syspro/dir2 ls../syspro/dir1 file1.txt ls -l../syspro/dir1/file1.txt... ls../syspro/dir2... ls -l../syspro/dir2/file2.txt -rw-r--r-- 1 syspro users... cat../syspro/dir2/file2.txt A test file ls../syspro/dir2/*.txt... ln../syspro/dir1/file1.txt ls -l../syspro/dir2/file2.txt Sep 8 12:45../syspro/dir2/file2.txt (bþ) 'Otan mða gonik diergasða dhmiourgeð diergasðec-paidiˆ, den eðnai dunatìn na epitôqoume epikoinwnða metaxô gonèa kai paidi n mèsw exwterik n/kajolik n metablht n, giatð oi metablhtèc autèc antistoiqðzontai se diaforetikèc jèseic mn mhc katˆ th dhmiourgða twn paidi n. EÐnai dunatìn ìmwc na petôqoume kˆti tètoio an kˆnoume dunamik dèsmeush mn mhc sto gonèa (me malloc), giatð o q roc ston opoðo desmeôetai aut (swrìc) eðnai koinìc gia to gonèa kai gia ta paidiˆ. AntÐstrofa, ìtan se mða diergasða to arqikì n ma dhmiourg sei èna pl joc apì ˆlla n mata, kˆje n ma èqei diaforetikì swrì, opìte den mporoôme na petôqoume epikoinwnða metaxô twn nhmˆtwn me dunamik dèsmeush mn mhc. En, me exwterikèc/kajolikèc metablhtèc, mporoôme na èqoume epikoinwnða metaxô twn nhmˆtwn, afoô o q roc pou fulˆssontai autèc eðnai koinìc gia ìla ta n mata mðac diergasðac. Sqoliˆste ta prohgoômena se 5 grammèc to polô. 2. Grˆyte èna prìgramma kelôfouc Bourne (èstw ìti onomˆzetai teams ) pou na sumbouleôetai èna arqeðo keimènou, to ìnoma-monopˆti tou opoðou eðnai h tim thc metablht c peribˆllontoc RESULTSFILE, sto opoðo perièqontai apotelèsmata podosfairik n ag nwn, èna se kˆje gramm tou arqeðou, sth morf teama - teamb : goalsa - goalsb (ta onìmata omˆdwn den perièqoun - :). To prìgramma pou ja grˆyete na upologðzei kai na ektup nei, gia kˆje omˆda pou tou dðnetai sth gramm entol c, to pl joc twn ag nwn pou èqei d sei, to sônolo twn bajm n pou èqei pˆrei (gia kˆje nðkh, mða omˆda paðrnei 3 bajmoôc, gia kˆje isopalða paðrnei 1 bajmì, en me tta den paðrnei bajmoôc), kaj c kai pìsa tèrmata èqei epitôqei kai pìsa èqei deqjeð. Jewr ste ìti to RESULTSFILE perièqei egguhmèna mìno grammèc sth swst touc morf. MÐa endeiktik ektèlesh faðnetai sthn epìmenh selðda. RESULTSFILE=results.txt ; export RESULTSFILE cat results.txt Cote d Ivoire-Serbia and Montenegro:3-2 Serbia and Montenegro-Netherlands:0-1 Netherlands-Cote d Ivoire:2-1 Netherlands-Argentina:0-0./teams Netherlands Cote d Ivoire Brazil Matches: 3 Points: 7 Goals for: 3 Goals against: 1 Team: Netherlands Matches: 2 Points: 3 Goals for: 4 Goals against: 4 Team: Cote d Ivoire Matches: 0 Points: 0 Goals for: 0 Goals against: 0 Team: Brazil 3. Grˆyte èna prìgramma C (upojèste ìti onomˆzetai thrseq ) to opoðo na kaleðtai me ènan arijmì n sth gramm entol c. To arqikì n ma thc diergasðac na dhmiourgeð èna nèo n ma, to opoðo na dhmiourgeð èna ˆllo, autì èna trðto, kai oôtw kajex c, èwc ìtou dhmiourghjoôn sunolikˆ n n mata, plhn tou arqikoô. Kˆje n ma, plhn tou teleutaðou, na perimènei na termatðsei to n ma pou dhmioôrghse kai metˆ na termatðzei kai autì epistrèfontac san kwdikì exìdou to ˆjroisma thc tautìthtˆc tou kai tou kwdikoô exìdou tou n matoc pou eðqe dhmiourg sei. To teleutaðo n ma na epistrèfei mìno thn tautìthtˆ tou. To arqikì n ma den epistrèfei kˆti. MÐa endeiktik ektèlesh eðnai h ex c:./thrseq 3 Level 3 (thread 16384): I created thread with id Level 2 (thread 16386): I created thread with id Level 0 (thread 49156): I didn t create any thread Level 1 (thread 32771): I created thread with id Level 1 (thread 32771): Thread with id returned Level 2 (thread 16386): Thread with id returned Level 3 (thread 16384): Thread with id returned DÐnetai sth sunèqeia tm ma C progrˆmmatoc, to ektelèsimo tou opoðou onomˆzetai prshmem. D ste èna pijanì apotèlesma thc entol c prshmem 5. Aitiolog ste sunoptikˆ thn apˆnths sac. main(int argc, char *argv[]) { struct sembuf op[3] = {{0, 0, 0}, {0, 0, 0}, {0, 1, 0}}; is = 0; n = atoi(argv[1]); op[0].sem_op = -n; op[1].sem_op = n; mid = shmget(shmkey, n*sizeof(int), PERMS IPC_CREAT); sid = semget(semkey, 1, PERMS IPC_CREAT); reg = shmat(mid, (char *) 0, 0); semctl(sid, 0, SETVAL, &is); numb = getpid(); for (i=1 ; i n ; i++) { pid = fork(); if (!pid) { *((int *) reg + i - 1) = numb; semop(sid, &op[2], 1); semop(sid, &op[0], 1); printf( %d %d\n , getpid(), *((int *) reg + i)); semop(sid, &op[1], 1); exit(0); } numb = pid; } *((int *) reg + n - 1) = numb; semop(sid, &op[2], 1); semop(sid, &op[0], 1); printf( %d %d\n , getpid(), *((int *) reg)); semop(sid, &op[1], 1);... } PROGRAMMATISMOS SUSTHMATOS Exetˆseic B' Periìdou (aþ) Parathr ste thn parakˆtw dialogik epikoinwnða me to kèlufoc kai sumplhr ste ti ja ektupwjeð ìpou upˆrqoun aposiwphtikˆ. Dikaiolog ste tic apant seic sac. An sthn teleutaða entol, h epilog sthn ls tan -l (antð gia -al ), ja paðrname to Ðdio apotèlesma; An ìqi, èqete na sqoliˆsete kˆti; ls -ld * drwxr-x spro users 512 Sep 4 15:13 mydir -rw-r spro users 7672 Sep 4 15:08 myfile cp myfile file1 ls -l file1 -rw-r spro users 7672 Sep 4 15:14 file1 ln myfile file2 chmod 700 myfile rm myfile ln file2 file3 ln -s mydir newdir cp file1 file4 ls -l file4 -rw-r spro users 7672 Sep 4 15:14 file4 ls -ld *... ls -al mydir grep ^d wc -l... (bþ) DÔo diergasðec P 1 kai P 2 epikoinwnoôn mèsw upodoq n ro c (stream sockets). H diergasða P 1 kˆnei treic kl seic eggraf c sthn upodoq thc S 1, se aprosdiìristec fˆseic thc ektèles c thc, kai grˆfei, katˆ seirˆ, ta mhnômata M 1, M 2 kai M 3. H diergasða P 2 kˆnei treic kl seic anˆgnwshc apì thn upodoq thc S 2, tic R 1, R 2 kai R 3, me th seirˆ aut, pˆli se aprìbleptec qronikèc stigmèc. Poia apì ta parakˆtw endeqìmena eðnai pijanì na sumboôn kai poia apokleðontai pantel c; i. H R 1 ja diabˆsei to m numa M 1, h R 2 to M 2 kai h R 3 to M 3. ii. H R 1 ja diabˆsei to m numa M 3, h R 2 to M 1 kai h R 3 to M 2. iii. H R 1 ja diabˆsei to m numa M 1 M 2 kai h R 2 to M 3. iv. H R 2 ja diabˆsei to m numa M 1 M 3 kai h R 3 to M 2. v. H R 1 ja diabˆsei to m numa M 1 M 2 M 3. vi. H R 1 ja diabˆsei to m numa M 1 kai h R 2 to M 2 M 3. Dikaiolog ste thn apˆnths sac. Upˆrqoun ˆlla pijanˆ endeqìmena, ektìc apì autˆ pou anafèrontai kai epilèxate; Poiec ja tan oi apant seic sac an h epikoinwnða metaxô twn diergasi n ginìtan mèsw thlegrafik n upodoq n (datagram sockets); An ginìtan mèsw swl nwn; 2. Grˆyte èna prìgramma gia to kèlufoc Bourne (èstw ìti onomˆzetai contwrd ) to opoðo na diabˆzei apì thn prokajorismènh eðsodo (stdin) èna keðmeno to opoðo na metafèrei sthn prokajorismènh èxodo (stdout), èqontac ìmwc diagrˆyei suneqìmenec emfanðseic Ðdiwn lèxewn perissìtero apì mða forˆ. Kˆje lèxh sthn èxodo na akoloujeðtai apì th s mansh / N, ìpou N eðnai to pl joc twn suneqìmenwn epanal yewn thc lèxhc sthn eðsodo. Epiplèon kenˆ metaxô twn lèxewn, sthn arq sto tèloc gramm n, akìma kai kenèc grammèc, na mhn metafèrontai sthn èxodo, sthn opoða ìmwc na diathreðtai h arqik dìmhsh se grammèc thc eisìdou, fusikˆ me thn exaðresh twn lèxewn pou èqoun diagrafeð. 'Ena parˆdeigma ektèleshc faðnetai parakˆtw, sto Sq ma 1. cat testf.txt This is a test test test test test test file file for the contwrd Bourne Bourne script. Have a look look look at at at it it it../contwrd testf.txt This/1 is/1 a/1 test/6 file/2 for/1 the/1 contwrd/1 Bourne/2 script./1 Have/1 a/1 look/3 at/3 it/2 it./1 while (!pthread_mutex_lock(&mtx)) { if (is_empty_queue(myqueue)) {... pthread_cond_wait(&cvar, &mtx);... continue; } item = remove_from_queue(myqueue);... while(needs_processing(item)) { newitem = process_item(&item);... insert_in_queue(myqueue, newitem);... } } Sq ma 1 Sq ma 2 3. Se mða polunhmatik efarmog, to arqikì n ma topojeteð stoiqeða proc epexergasða se mða kajolikˆ prospelˆsimh ourˆ kai, sth sunèqeia, dhmiourgeð NWorkers n mata-ergˆtec, ta opoða diaqeirðzontai thn ourˆ gia na epexergasjoôn ta dedomèna pou perièqei. Kˆje ergˆthc, ìtan den èqei douleiˆ, exˆgei kˆpoio stoiqeðo apì thn ourˆ, to epexergˆzetai kai, analìgwc me to apotèlesma thc epexergasðac, endèqetai na prosjèsei sthn ourˆ kai kˆpoia nèa stoiqeða gia epexergasða apì ergˆtec, pijan c kai ton Ðdio. Metˆ suneqðzei paðrnontac nèo stoiqeðo apì thn ourˆ gia epexergasða. H koin prospˆjeia twn ergat n termatðzei ìtan den upˆrqei, kai eðnai bèbaio ìti den ja upˆrxei, ˆllo stoiqeðo sthn ourˆ gia epexergasða. To apìspasma k dika C pou faðnetai parapˆnw (Sq ma 2) proèrqetai apì th sunˆrthsh twn nhmˆtwn-ergat n. Sumplhr ste to apìspasma autì, ìpou upˆrqoun aposiwphtikˆ, gia na epiteuqjeð h epijumht sumperiforˆ. MporeÐte na qrhsimopoi sete kai epiplèon, exwterikèc ìqi, metablhtèc, ìqi ìmwc shmatofìrouc metablhtèc sunj khc, plhn aut n pou perilambˆnontai dh sto apìspasma. 'O,ti sunart seic qrhsimopoioôntai, jewr ste ìti èqoun oristeð katˆllhla. 4. Grˆyte èna prìgramma C (upojèste ìti onomˆzetai sigcyc ) pou na kaleðtai me dôo orðsmata N kai M sth gramm entol c. H diergasða-gonèac na dhmiourgeð arqikˆ N diergasðec-paidiˆ kai sth sunèqeia na stèlnei èna s ma SIGUSR1 sto N -ostì paidð. Autì, ìtan paralˆbei to s ma, na steðlei epðshc èna s ma SIGUSR1 sto prohgoômenì tou, to N 1 tˆxhc, autì sto prohgoômenì tou kai oôtw kaj' ex c. To 1o paidð na steðlei to s ma sto gonèa touc. Aut h kuklik diˆdosh tou s matoc na gðnei sunolikˆ M forèc. 'Ena parˆdeigma ektèleshc eðnai to ex c:./sigcyc 3 2 Cycle 1: Process 0 (pid=11651) sending signal to Cycle 1: Process 3 (pid=11654) sending signal to Cycle 1: Process 2 (pid=11653) sending signal to Cycle 1: Process 1 (pid=11652) sending signal to Cycle 2: Process 0 (pid=11651) sending signal to Cycle 2: Process 3 (pid=11654) sending signal to Cycle 2: Process 2 (pid=11653) sending signal to Cycle 2: Process 1 (pid=11652) sending signal to 11651 PROGRAMMATISMOS SUSTHMATOS Exetˆseic A' Periìdou (aþ) H entol find dir -name name -print yˆqnei ston katˆlogo dir, kai anadromikˆ se ìlouc touc upokatalìgouc tou, gia kìmbouc sto ierarqikì sôsthma arqeðwn pou to ìnoma touc tairiˆzei me to name kai ektup nei ta onìmata monopˆtia twn kìmbwn pou brðskei. Parathr ste th dialogik epikoinwnða me to kèlufoc sto Sq ma 1 kai breðte tð ja ektupwjeð ìpou upˆrqoun aposiwphtikˆ. Dikaiolog ste stoiqeiwd c thn apˆnths sac. (bþ) Poia tan, katˆ th gn mh sac, h prìjesh tou programmatist pou ègraye to prìgramma C sto Sq ma 2; D ste mða pijan ektôpwsh tou antðstoiqou ektelèsimou progrˆmmatoc (an ìlec oi kl seic sust matoc leitourg soun qwrðc prìblhma). Upˆrqei kˆpoio polô sobarì sqediastikì lˆjoc sto prìgramma autì; An nai, exhg ste poio eðnai kai proteðnete polô sôntoma toulˆqiston dôo trìpouc me touc opoðouc ja mporoôse na diorjwjeð to prìblhma autì. ls. dir.: dir exfind.c dir: a_file.c exfind.c find. -name *.c -print... cat exfind.c main() { execlp( find , find , . , -name , *.c , -print , NULL); perror( execlp ); } cc -o exfind exfind.c find. -name *.c -print..../exfind... #include signal.h int p[4] = {0, 0, 0, 0}; void handler(int sig) { printf( %d: %d %d %d %d\n , getpid(), p[0], p[1], p[2], p[3]); } main() { int i, pid, st; signal(sigusr1, handler); for (i=0 ; i 4 ; i++) { pid = fork(); if (!pid) { pause(); exit(0); } p[i] = pid; } for (i=0 ; i 4 ; i++) kill(p[i], SIGUSR1); kill(getpid(), SIGUSR1); for (i=0 ; i 4 ; i++) wait(&st); } Sq ma 1 Sq ma 2 2. 'Ena keðmeno se fusik gl ssa eðnai apodektì apì pleurˆc emfˆnishc ìtan upˆrqei akrib c èna kenì metaxô twn lèxewn kai ìtan den upˆrqoun kenˆ prin apì ta shmeða stðxhc (teleðec, kìmmata, klp.). EpÐshc, ìtan èna shmeðo stðxhc akoloujeðtai apì lèxh, prèpei na upˆrqei akrib c èna kenì metaxô autoô kai thc lèxhc pou akoloujeð. Grˆyte èna prìgramma gia to kèlufoc Bourne (èstw ìti onomˆzetai punct ) to opoðo na diabˆzei apì thn prokajorismènh eðsodo (stdin) èna arqeðo keimènou kai, efarmìzontac to prohgoômeno aisjhtikì axðwma, na to xanagrˆfei sthn prokajorismènh èxodo (stdout) me komyì trìpo. Upojèste ìti ìla ta pijanˆ shmeða stðxhc eðnai kataqwrhmèna sth metablht peribˆllontoc PMARKS. 'Ena parˆdeigma ektèleshc eðnai to akìloujo: PMARKS=.,?! ; export PMARKS cat inp_file Oh, my God!!! What an ugly file, isn t it? Yes,it is../punct inp_file Oh, my God!!! What an ugly file, isn t it? Yes, it is. 3. Poia tan, katˆ th gn mh sac, h prìjesh tou programmatist pou ègraye to parakˆtw prìgramma C; Parìti to prìgramma autì metaglwttðzetai me epituqða, èqei diˆfora sobarˆ logikˆ lˆjh. Grˆyte mða swst ekdoq tou, me bˆsh thn apˆnths sac sthn arqik er thsh. #include pthread.h int i, j, count = 0; pthread_t ker_id, pi_id; pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cvar = PTHREAD_COND_INITIALIZER; void *kernighan(void *argp) { printf( i am Kernighan version %d\n , *(int *) argp); for (j=0 ; j 30000 ; j++) { pthread_mutex_lock(&mtx); count++; if (count == 25000) { pthread_cond_signal(&cvar); printf( %d: Signaled\n , ker_id); } pthread_mutex_unlock(&mtx); } } void *pike(void *argp) { printf( i am Pike the only one\n ); pthread_cond_wait(&cvar, &mtx); printf( %d: Woke up\n , pi_id); } main() { for (i=0 ; i 5 ; i++) pthread_create(&ker_id, NULL, kernighan, (void *) &i); pthread_create(&pi_id, NULL, pike, NULL); for (i=0 ; i 5 ; i++) pthread_join(ker_id, NULL); pthread_join(pi_id, NULL); } 4. Grˆyte dôo progrˆmmata C (èstw ìti onomˆzontai filein kai fileout ) tètoia ste to pr to na diabˆzei thn prokajorismènh eðsodì tou (stdin) kai na thn stèlnei sto deôtero mèsw mðac ourˆc mhnumˆtwn.
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks