Enums, Sockets, Threads Flashcards

1
Q

Define what an Enumeration is, as well as it’s purpose…

A

A way of specifying a set of integer constants, each of which is represented by a variable name.

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

What is the default start value of Enums? What happens if you assign a different integer to the first value?

A
  1. If the first number is changed, the following numbers will be be incremented accordingly.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In an enum of 10 members, if the first 5 constants are 0-5 integers, but then the 5th is changes to 88. What will the integer constants of 5 to 10 be?

A

88,89,90,91,92

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

Write a small program to give an example of an Enumeration…

A

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

What does the telnet command do? Give an example of telnet in use…

A

telnet connects the terminal to a remote server e.g. telnet computerscience.ac.uk 80

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

Define the roles of sockets on a network…

A

Sockets enable nodes (hosts) on a network to communication with each other.

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

In most systems that use sockets, what language is the fundamental low-level socket that peripheral sockets all filter down to developed in?

A

Most systems have a core C socket, which other sockets filter down to.

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

What are the 2 sides of a Socket interaction across a network called?

A

Client Server.

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

What are the 7 steps that a Server Side socket conducts to interact with a Client Socket?

A

Create socket; set socket options; Bind listener to port number; Listen; Accept client request; Exchange data; Close connection.

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

What are the 3 steps that a Client Side socket conducts to interact with a Server socket?

A

Create socket; Request a connection; Exchange data.

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

When a Server Socket is listening on a port, what type of process is doing the listening?

A

Http Daemon process listens for connection on the socket port.

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

What is a daemon process in Linux?

A

A background process

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

Which of the fundamental processes is used to enable data exchange between the 2 sockets?

A

Pipe

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

Which command is used to create a pipe between a pair of sockets?

A

popen( ) -> Pipes between 2 sockets.

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

With regards to exchanging data, what is the difference between using pipes as opposed to raw sockets?

A

Using popen( ) opens a buffered stream between sockets. Thus, it’s safer and quicker.

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

Since C doesn’t have native threading, which API does it use or threading?

A

POSIX -> Portable OS Interface

17
Q

What is pthreads? Where is it utilised?

A

pthreads is a multi-threading model used by many modern languages, and exists independently of any language.

18
Q

Which statement would be used to declare 3 threads?

A

pthread_t -> e.g pthread_t my_threads(3);

19
Q

What is mutex? What problem does it solve? What issue can it cause?

A

Locks a resource so only 1 thread can execute on it at any given time. However, Causes idle time for waiting threads.

20
Q

What signalling mechanism do we use to signal that a resource is free for a thread to use?

A

Semaphore

21
Q

What value does semaphore return to indicate that the resource is free?

A

Non-zero. If the semaphore returns a non-zero value, the resource is free.