Source Code ASCII Format

Source Code ASCII Format

<p> Unix-Linux 1</p><p>Source code – ASCII format Binary code – runable binary format Object code – special intermediate code</p><p>Library (archive) Files  /usr/lib  /usr/local/lib</p><p> Library Functions -- Runtime Library Procedures o Static Libraries  collections stored in object code to be used during linking phase</p><p> o Shared Object Libraries  relocatable objects to be shared by more than one process</p><p> o library file prefix – lib o library file extension -- .a</p><p> Unix archive utility – ar  used to create libraries  modify libraries  extract members from a library  insert members into an existing library </p><p>Unix Manual Appendix A  Synopsis Section o List of the required “include” files, function prototypes, external variables, etc. e.g., $man perror  #include <stdio.h> void perror(const char *s) #include<error.h> const char *sys_errlist[ ]; Int sys_nerr; Managing Failure – see text</p><p>Process Memory  Text Segment  Data Segment  Stack Segment  u-Area Process Memory Addresses The addresses of the external variables  etext  edata  end correspond respectively to the first valid address above the segments  text  initialized data  unutilized data</p><p>Creating a Process  Startup – kernel BSD Unix Solaris o swapper pid 0 sched or fsflush o init pid 1 init o pagedaemon pid 2 pageout  User – children of init, i.e., pid 1</p><p>Process Environment  Process Group ID  parent is process group leader  parent pid == process group pid o descendents of the parent are members of the group o signals to process group  getpgpid( )  returns process group pid to the calling member of the group  setpgpid(pgpid)  changes process group to the specified group-pid, i.e., pgpid  stpgpid(0)  calling process becomes the group leader</p><p>Permissions $ls –l  displays permission numbers of all files listed $ls .*  displays all hidden files in current directory e.g., .exrc  startup info for vi :set numbers  files r w x  directories o r  display o w  files/links can be inserted or deleted o x  directory can be traversed, i.e., files listed in the directory can be accessed creation mask  executable files 777  directories 777  text files 666</p><p> umask  default – system administrator – 022  .login or .profile file o $umask nnn where nnn is the  new umask value  new umask value XOR creation mask value  the desired new permission number</p><p> e.g., to obtain permission numbers of 700 for all new text files, the umask value should be set to 166  e.g., to obtain permission numbers of 700 for all new  executable files  directories the umask value should be set to 077</p><p>Privacy  create new files, directories, executable files  check the permissions granted  after creation, use chmod( ) to change the mode to the desired setting </p><p>Real User & & ID’s Effective Group </p><p> real user ID (UID) user real group ID (GID)  maps to group names stored in /etc/group maximum(UID, GID) found in the defined constant maxid located in <sys.param.h> file File Systems</p><p>User Space</p><p>Kernel Space u-area u-area fd fd</p><p>System System File Inode Table Table System Calls  status  stat data structure o stat o lstat o fstat  change mode o chmode – char * reference o fchmod – integer file descriptor number  umask o returns old umask value o which, if saved, can be used to restore the previous setting  getcwd -- returns a pointer to the current working directory pathname  chdir – change directory o no argument  returns to the users home directory o /  root directory o ../  parent directory o ./comp322 subdirectory 322</p><p>Resource Limits  Resources o cputime o filesize o datasize – data+stack segment size o stacksize -- stack segment size o coredumpsize – core dump file size o descriptors – number of file descriptors</p><p> $limit  soft limits – limits that can be changed by the user  $limit –h  hard limits – limits that can only be increased by the superuser  ulimit  getrlimit  setrlimit  sysconfig</p><p>Signaling Processes  event requiring attention  signal  signal – software generated  generated by o hardware  attempt to address space outside its own address space  divide by zero o kernel – notifying process that an I/O device is available o other processes – child process notifying parent process that it is terminating o user – keyboard signal  quit  interrupt  stop signal Potential Process Actions  perform the system-specified default action a) notify parent of termination b) generate a core file – current memory image c) terminate  ignore the signal a) cannot ignore SIG-STOP (23) b) cannot ignore SIGKILL (9)  catch the signal a) invoke a special signal handling routine b) after execution of the routine, the process, if appropriate, resumes where it left off c) exceptions o cannot catch SIG-STOP (23) o cannot catch SIGKILL (9)</p><p>Command Line Values void main(int argc, char *argv[ ]) { for( ; *argv; ++argv) printf(“%s\n”, *argv); //new versions of Unix for(int i = 0; i < argc; i++) printf(“%s\n”, *argv); // any version of Unix }</p><p>$a.out this is a test</p><p> argc argv “a.out “this” “is” “a” “test”</p><p>Ξ (null) getopt( ) – see textbook Environmental Variables</p><p> </p><p> $man –s5 environ  detailed description of common environmental variables  char *getenv( );</p><p> int putenv(char *string);  environmental variables are stored in Process Memory o Process Memory is fixed in size o environmental variables can be modified by the process but not expanded </p><p> changing environmental variables by o adding new variables o modifying variables in such a way that it requires additional storage space is discouraged unless one investigates the ramifications very carefully!</p><p> addresses associated with environmental variables are changed when a new environmental variable is added  child processes inherit a copy of the environmental variables from the parent</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us