Operating System-Unix [3i Infotech Placement]: Sample Questions 16 - 18 of 78

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 16

Edit

Write in Short

Short Answer▾

How can you get/set an environment variable from a program?

Explanation

  • An environment variable is accessed using getenv () .
  • And set using the function putenv () .

Question 17

Edit

Describe in Detail

Essay▾

What happens when you execute a program?

Explanation

  • When we execute program in Unix, system provides an independent environment with process context containing all the required details of state of program.
  • Every time program executes system fork system sets up a context required to execute the program.
  • Following steps are involved:
    • Allocate slot in process table.
    • Assign unique id called PID (process ID)
    • Process context is copied from the parent which requested the spawn (create) of new process.
    • Returns PID to parent and control the new process.

Question 18

Edit

Describe in Detail

Essay▾

What are the UNIX system calls for I/O?

Explanation

  • creat (name, permissions) :
    • Used to creat a file with the name and mode specified.
    • Permission would a number.
  • open (name, mode)
    • Used to open a file name
  • close (fd)
    • Closes an opened file.
  • unlink (fd)
    • Deletes a file.
  • read (fd, buffer, n_to_read)
    • Reads data from a file.
  • write (fd, buffer, n_to_write)
    • Writes data to a file.
  • Iseek (fd, offset, whence)
    • Moves the read/write pointer to the specified location
  • Dup
    • Makes a duplicate copy of existing file descriptor.
  • Fcntl
    • Makes the changes to the properties of an open file.

Developed by: