Skip to main content

Linux

Linux-(Files and IPC)


1) Explain chmod and umask commands

Ans:

        a)  CHMOD: To change the existing file permission,we can change file permission to new permission or can change one permission alone.

                           eg:
                                 chmod 0664 file_name
                                    rwx   rwx     rxx
                                      user group  others

       b)  UMASK: When you create a file or directory, the default file permissions assigned to the file or directory are controlled by the user mask.
  • To check the umask value type umask and press enter. This will shows octal value 0664
  • umask -S this will shows in string  eg - rwx rwx rxx
  • once we change the umask value then new creating files permission updated to umask value.

--------------------------------------------------------------------------------------------------------

2) Explain 5 members of stat structure.

Ans:
  •      st_atime
  •      st_mtime
  •      st_ctime
  •      st_size
  •      st_mode

--------------------------------------------------------------------------------------------------------

3) Explain the prototypes of below functions
a) opendir() b) readdir() c)time() d) ctime() e)open()

Ans:
a) DIR *opendir(const char *name); Open directory
b) struct dirent *readdir(DIR *dirp); Read directory 
c)time_t time(time_t *t);                   Get the time in seconds
d)char* ctime(const time_t *t);         to change time into ASCII
e)int open(const char *pathname,int flags); to open files
   int open(const char *pathname,int flags,mode_t mode);

--------------------------------------------------------------------------------------------------------

4) Explain output and input redirection with one simple example.

Output redirection is STDOUT  redirect to a file
Input redirection is  STDIN  redirect to a file (Instead of keyboard, CPU will get data from file)

Prgm: Click here
Prgm header.h: Click here

--------------------------------------------------------------------------------------------------------

5) Why IPC required? Explain it.

IPC allows one process to control another process, so data sharing can do without any interference. by using this mechanism (PIPE, FIFO,MESSAGE QUEUE,SHARED MEMORY, SEMAPHORES)we can communicate one process to another process. IPC facilitates efficient data transfer between processes.

--------------------------------------------------------------------------------------------------------

6) WAP to create 3 child processes where parent need to put 15 bytes in pipe and all 3 child's need to read 5 bytes each and print.

Prgm : Click here
Prgm header.h: Click here

--------------------------------------------------------------------------------------------------------

7) p1 process need to send one structure to p2 which contain 2 operands and 1 operator. p2 need to do operation and send result to p1. P1 need to display result use FIFO (10 Marks)
Note: p1.c and p2.c two separate programs need to submit.

Prgm P1.c: Click here
Prgm P2.c: Click here
Prgm header.h: Click here


--------------------------------------------------------------------------------------------------------


8) p1 process need to get file info using stat() and put into shared memory and p2 process need to read and print any five members of that structure. (10 Marks).
Note: p1.c and p2.c two separate programs need to submit.

Prgm P1.c : Click here
Prgm P2.c : Click here
Prgm header.h: Click here




********************************Thank you!!!😊*************************************

Comments

  1. Thanks. It was really useful.

    ReplyDelete
  2. Mr Benjamin went above and beyond their requirements to assist me with my loan which I used to expand my pharmacy business,They were friendly, professional, and absolute gems to work with.I will recommend  anyone looking for loan to contact. 247officedept@gmail.com.WhatsApp ... + 19893943740.








    ReplyDelete

Post a Comment

Popular posts from this blog

Ultrasonic sensor using Arduino Code /*     CAR PARKING SENSOR    https://electronicassit.blogspot.in    ARJUN ARANGIL    9444868542 */ // Define pins for ultrasonic and buzzer int const trigPin = 5; int const echoPin = 6; int const buzzPin = 12; void setup() { pinMode(trigPin, OUTPUT); // trig pin will have pulses output pinMode(echoPin, INPUT); // echo pin should be input to get pulse width pinMode(buzzPin, OUTPUT); // buzz pin is output to control buzzering } void loop() { // Duration will be the input pulse width and distance will be the distance to the obstacle in centimeters int duration, distance; // Output pulse with 1ms width on trigPin digitalWrite(trigPin, HIGH); delay(1); digitalWrite(trigPin, LOW); // Measure the pulse input in echo pin duration = pulseIn(echoPin, HIGH); // Distance is half the duration devided by 29.1 (from data...
PIR Senesor / Motion Sensor using Arduino  Code /* PIR SENSOR / MOTION SENSOR https://electronicassist.blogspot.in/ ARJUN ARANGIL 9444868542 */ int ledPin   = 13;                 // choose the pin for the LED int inputPin = 2;                  // choose the input pin (for PIR sensor) int leda     = 12;                 // choose the pin for the LED int ledb     = 11;                 // choose the pin for the LED int pirState = LOW;                // we start, assuming no motion detected int val      = 0;                  // variable for reading the pin status void setup()  {   pinMode(ledPin, OUTPUT);        ...
#Lesson 01- Blinking LED                 The simplest thing you can do with a Arduino to blinks the LED Hardware Required   -   Arduino Board   -  LED   -  220 Ω Resistor   -  Jumper wire   -  Bread board Circuit       The LED is connected to Arduino digital pins and 220Ω resistor is connected series in between Arduino and LED. The resistor which limits the flow of currents.      Connect one end of the resistor to the digital pin correspondent to the LED. Connect the long leg of the LED (+ve leg called as anode) to the other end of the resistor and connect the short leg of the LED (-ve leg called as cathode) to the Gnd Code After you build the circuit plug the Arduino into your computer, start the Arduino software(IDE) and enter the code given below /*   Blink   https://electronicassit.blogspot.in/   9444868542 *...