week 6 - L3 - System Calls Flashcards

1
Q

system calls

  1. what are they?
  2. what may this include?
  3. how do we make a system call in Linux?
  4. examples
A

1.
A system call is how a program sends requests to the kernel

  1. This may include:
    • hardware related services
    • CREATING and EXECUTING a new process
    • communicating with integral kernel

3.
A system call is made by writing a C function that call a kernel function with matching arguments

  1. examples include : fork(), wait(), execve(), write
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

system calls

  1. what are they interface between?
  2. what are they dependent on? what can they be invoked by?
  3. what happens in a computing ?
  4. what are interrupts?
A

1.
System calls are interface between OS and user programs(to perform privileged operations)

2.
- they are machine dependant but can be invoked by standard procedure libraries

3.
- In computing a system call is the PROGRAMMATIC WAY in which a computer requests a service from the kernel of the operating system it is executed on

    • In system programming and interrupt is a signal to the processor emitted by the software or hardware indicating an event that needs immediate attention
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
system calls - tools
- who do they provide help for? 
- what are they part of?
- what do they range from?
-
A

System calls
- Are tools that provide help to other program
- Not strictly part of the O/S but provide a convenient environment for program development and execution
- They go from simple libraries( #include library name at the top) to full-fledged editors
-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. what are the most important programs?

2. examples of each

A

The most important programs

  • Programs that LUNCH programs
  • Programs that help COMPILE programs
  • Programs that help DEVELOP programs
    • Programs that LUNCH programs: command interpreters (shells)
    • Programs that help COMPILE programs: compilers, assemblers, linkers, loaders, debuggers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  • why are system calls considered a special set of functions?
  • where does the control go from and to?
  • what does the kernel communicate back? and through what?
  • why are system calls not normal functions?
  • why may the user program be blocked?
A

System call – set of functions

  • System calls can be considered as a special SET OF FUNCTIONS used by programs (usually C) which provide transition from user to kernel mode
  • Transition = handover
  • user mode -> kernel mode
  • the kernel can communicate back to a user program through a RETURN VALUE or by using a BUFFER
  • system calls are not normal function calls because control given to the kernel to perform the system call
  • depending on the system call the user program may be blocked by the OS until the system call has finished
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Main categories of system calls

A

Main categories of system calls

  • process creation and management
  • file access
  • directory and file-system management
  • main/memory management
  • I/O handling
  • Protection
  • Networking
  • Information maintenance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  • why can system calls only be invoked by special functions?
  • what does a system call allow the process to do?
  • how is it done?
A
  • The reason why syscalls can only be invoked by special functions is because when processes run they cannot read and execute data that is part of the kernel as each process is expected to run in user space confined to its own part of memory (virtual memory)
  • A system call can allow a process to break out of its “user space box”
  • This is done by using a special assembly instruction and specifying a system call number which in turn causes the CPU to look up an address which corresponds to that system call
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

system call dispatch table

  • where is it placed?
  • how can you access it?
  • what does each entry contain?
A
System call dispatch table
-	It’s placed inside the address space of each process (Above the stack)
-	ONLY ACCESSIBLE with a system call
-	The table has indexes. These correspond to different system calls 
-	For example
o	0 – address of read syscall code
o	1 – address of write syscall code 
o	Etc …
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

address space - static data

- what is it?

A

A static data is data which remains the same over the lifetime of the entire run program e.g. “Hello world”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Write syscall

  • where is the data copied from and to?
  • how does the C write function work?
  • what include does it require?
  • where is the data copied first? and after that?
A

Write syscall

  • In C we have a “write” function
  • What this does is invokes the write syscall that copies bytes from process memory to a file
  • It takes as parameters:
  • A FILE DESCRIPTOR,
  • A POINTER TO THE DATA TO BE COPIED
  • THE BYTE COUNT VALUE
  • A file descriptor “fd” is a number in a process which uniquely identifies an open file
  • When calling a read/write file system call you do not pass a file path but a file descriptor
  • You can use the open system call to return a file descriptor when opening a file by passing a path
  • The write system call requires the include file “#include ”
  • A call to write copies the data from the process to a write buffer controlled by the kernel OS
  • The kernel then writes the data to the device
  • When writing a file to a storage device such as a hard drive the data is not directly copied from the processor to a hard rive, but is copied to a buffer in memory outside the process and controlled by the kernel
  • The kernel then writes the data from the buffer to the storage device (hard disk)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly