Weekly Notes for Week 08

Tutorial Session Week 08

Prepare for the Tutorial Session in Week 08 from Chapter 2 the following exercises

  1. What is the purpose of system calls?
  2. What system calls have to be executed by a command interpreter or shell in order to start a new process on a UNIX system?
  3. What is the purpose of system programs?
  4. What is the main advantage of the layered approach to system design? What are the disadvantages of the layered approach?
  5. List five services provided by an operating system, and explain how each creates convenience for users. In which cases would it be impossible for user-level programs to provide these services? Explain your answer.
  6. How could a system be designed to allow a choice of operating systems from which to boot? What would the bootstrap program need to do?
  7. What are the advantages and disadvantages of using the same system-call interface for manipulating both files and devices?
  8. Describe why Android uses ahead-of-time (AOT) rather than just-in-time (JIT) compilation.
  9. How are iOS and Android similar? How are they different?
  10. What are the two models of interprocess communication? What are the strengths and weaknesses of the two approaches?
  11. What is the main advantage of the microkernel approach to system design? How do user programs and system services interact in a micro-kernel architecture? What are the disadvantages of using the microkernel approach?

Some more C programming exercises:


#include <stdio.h>

int main(int argc, char** argv)
{
  stupid();
  stupid();
  return 0; 
}

int stupid()
{
  static int i=17;
  printf("i is %d\n", i);
  i++;
}

#include <stdio.h>
#include <stdlib.h>

static int comp(const void * x, const void * y)
{
  int a = (int)(*(int*)x);
  int b = (int)(*(int*)y);

  if (a==b)
    return 0;
  else
    if (a < b)
        return -1;
    else
        return 1;
}

int main(int argc, char* argv[])
{
   int numbers[10]={1892,45,200,-98,4087,5,-12345,1087,88,-100000};
   int i;

  /* Sort the array */
  qsort(numbers,10,sizeof(int),comp) ;
  for (i=0;i<9;i++)
    printf("Number = %d\n",numbers[ i ]) ;
  return 0;
}

#include <stdio.h>

#define SQR(a)((a)*(a))
#define CUB(a)((a)*(a)*(a))


inline static int cub(int x) { return x*x*x; }

int main()
{
        int x;

        x=3;
        printf("square? :%d\n",SQR(x));
        printf("x:       %d\n",x);

        x=3;
        printf("square? :%d\n",SQR(++x));
        printf("x:       %d\n",x);

        x=3;
        printf("cub?    :%d\n",CUB(x++));
        printf("x:       %d\n",x);

        x=3;
        printf("cub?    :%d\n",CUB(++x));
        printf("x:       %d\n",x);

        x=3;
        printf("cub?    :%d\n",cub(++x));
        printf("x:       %d\n",x);

        return 0;
}