Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

linux systemski proces, gcc ,debian..

[es] :: C/C++ programiranje :: C/C++ za početnike :: linux systemski proces, gcc ,debian..

[ Pregleda: 2917 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

kunc
Germany/Munich

Član broj: 195484
Poruke: 440



+56 Profil

icon linux systemski proces, gcc ,debian..22.05.2015. u 22:08 - pre 107 meseci
Znaci obični program, skolski primjer. Trebam dodat na ovaj cod jednu sistemsku funkciju..bilo koju, bilo kakvu. Moze li neko pomoći i slično ?! Hvala unaprijed
Code:
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdlib.h>
int Id; /* identifikacijski broj segmenta */
int *ZajednickaVarijabla;
 
void Pisac(int i)
{
   *ZajednickaVarijabla = i;
}
void Citac(void)
{
   int i;
   do {
      i = *ZajednickaVarijabla;
      printf("Procitano %d\n", i);
      sleep(1);
   } while (i == 0);
   printf("Procitano je: %d\n", i);
}
void brisi(int sig)
{
   /* oslobađanje zajedničke memorije */
   (void) shmdt((char *) ZajednickaVarijabla);
   (void) shmctl(Id, IPC_RMID, NULL);
   exit(0);
}
int main(void)
{
   /* zauzimanje zajedničke memorije */
   Id = shmget(IPC_PRIVATE, sizeof(int)*100, 0600);
   /* sizeof(int) je dovoljno memorije, ali u nekim slucajevima (pinus) 
      treba zatraziti vise memorije, pa je u primjeru broj pomnozen sa 100 */
 
   if (Id == -1)
      exit(1);  /* greška - nema zajedničke memorije */
 
   ZajednickaVarijabla = (int *) shmat(Id, NULL, 0);
   *ZajednickaVarijabla = 0;
   sigset(SIGINT, brisi);//u slučaju prekida briši memoriju
 
   /* pokretanje paralelnih procesa */
   if (fork() == 0) {
      Citac();
      exit(0);
   }
   if (fork() == 0) {
      sleep(5);
      Pisac(123);
      exit(0);
   }
   (void) wait(NULL);
   (void) wait(NULL);
   brisi(0);
 
   return 0;
}




 
Odgovor na temu

Texas Instruments

Član broj: 227540
Poruke: 272
95.180.68.*



+61 Profil

icon Re: linux systemski proces, gcc ,debian..22.05.2015. u 23:17 - pre 107 meseci
Recimo na početku programa možeš da ispišeš ime sistema, verziju, arhitekturu...

Code:

#include <sys/utsname.h>
...
struct utsname u;
uname(&u);
printf("%s release %s (version %s) on %s\n", u.sysname, u.release, u.version, u.machine);
...
 
Odgovor na temu

DusanSukovic
Dušan Šulović
Na krevetu

Član broj: 35637
Poruke: 1371

Sajt: www.MotoBoem.RS


+460 Profil

icon Re: linux systemski proces, gcc ,debian..16.09.2015. u 13:07 - pre 103 meseci
Citat:

If you don't know where to start, type man intro, or man -s <section> intro. This gives you a summary of commands of requested section.

Sections are well defined:

1 is for shell commands,
2 is for system calls,
3 is for programming interfaces (sometimes 3C for C, 3F for Fortran...)
5 is for file formats and other rules such as printf or regex formats.

Last but not least: information delivered in man pages is not redundant, so read carefully from beginning to end for increasing your chances to find what you need.



http://unix.stackexchange.com/...nding-information-in-man-pages


Stane Dolanc: "Bavljenje tehnikom treba da postane svakodnevna potreba coveka.."
 
Odgovor na temu

[es] :: C/C++ programiranje :: C/C++ za početnike :: linux systemski proces, gcc ,debian..

[ Pregleda: 2917 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.