Problem 3.1
Define the concepts of modularity and layering:
Modularity - subdivide a system into smaller parts (modules) that can be independently created and then used in different systems to drive multiple functionalities. Layering – modular design when each layer communicates only with adjacent layers
a) Modularity allows for flexibility in the design of a system, as the parts of the OS that need to be used are dynamically loaded as modules at runtime. This can allow for easy expansion of the OS capabilities. A downside is that performance can suffer if many modules need to be loaded before a task can be completed.
b) The main advantage of layering is the simplicity of debugging.
c) Modularity and layering are related, as both are structures of an operating system.
d) The Mach operating system operates using a microkernel. An advantage of this is that the kernel is far smaller and less complex than the monolithic kernels of other OS’s such as UNIX. Another benefit is the easy ability to modify the kernel and port it to other systems. A disadvantage is decreased performance. The microkernel is another method of adding modularity to the OS, along with layering and modules.
Problem 3.2
a) A communication protocol is a set of rules and formats for exchanging messages between computer systems.
b) There are four layers in the IP stack. The link layer contains technology for a LAN, the internet layer establishes networked communication, the transport layer handles host to host communication, and the application layer contains protocols for process to process communication.
c) The layered architecture allows for communication using the lowest layer possible.
d) The internet is based on an hourglass structure because everything is routed through a bottleneck in the form of the IP protocol during encapsulation.
e) Encapsulation is the process of adding control information as a message passes through the layers of communication, de-capsulation is the opposite. Headers are added in each of the layers, which allow abstraction of the actual communication between computers and focuses on the relevant user information.
Problem 3.3
a) The kernel of an OS, in regards to networking, has to regulate the network traffic, and it does so by time division multiplexing. It packages network traffic and sends it out by dividing out time slots to individual packets of information. It multiplexes the information, sends it out when it is time, and then demultiplexes it when it arrives.
b) Inetd: listends on designated ports used by internet services.
Httpd: the HTTP daemon that handles communication with those kinds of clients and servers.
Ftpd: the FTP daemon that handles those kinds of protocols.
Telnetd: handles communication using the Telnet protocol.
c) Ports are how processes identify themselves to networking protocols, some ports are always used for certain protocols, such as port 80 for HTTP. Sockets are the endpoints for process communication; the address is a concatenation of the IP address and port.
d) Sockets implement two queues one for incoming and one for outgoing messages for a process.
Problem 3.4
Define the concepts of message passing and shared-memory communication.
Message passing is a method of inter-process communication in which processes directly communicate using various methods of sending data in the form of messages to one another. Shared memory is a method in of inter-process communication where processes have access to the shared memory addresses which would normally be prevented by the OS.
a) When a process wants to communicate, it can do so directly or indirectly. Under direct communication, each process that wants to communicate must explicitly name the recipient or sender of the communication. A link is established between the two processes, and they share data. However, this method limits modularity of the resulting process definitions.
When a process communicates indirectly, messages are sent to a mailbox or ports, and later received. Every message has a unique identifier, and there does not have to be a lone recipient of the message shared.
b) Both send() and receive() primitives are needed. The send primitive needs the process identifier or mailbox identifier as the destination and the message as in send(P, message) or send(A, message). The receive primitive needs the source process identifier or source mailbox identifier and the message, as in receive(id, message) and receive(Q, message) respectively.
c) Blocking send/receive – the process blocks until the message is received/until a message is available. Non-blocking send, the process sends the message and resumes normal operation, receive, the process either receives a message or null. Blocking is synchronous, meaning the opposite process must perform the opposite function to complete. Non-blocking is asynchronous, the opposite function can be performed at any time after the original.
Problem 3.5
List several client-server systems you are familiar with.
E-mail, WWW, GPS
a) The client-server model offers centralization of possibly limited resources for use by many clients, flexibility of expanding or shrinking the network easily, allows for easy updates, scales well, and simplifies security enforcement. It also separates functions and their implementation clearly.
b) A stateless server does not keep record of the clients and treats each requests as stand-alone transaction.
c) A trusted intermediary is a trusted service that supports buffered communication by providing a queue that can sort messages and allow for increased flexibility.
d) Pushing a message to an intermediary allows it to be stored until it is pulled by a recipient.
e) Yes, by pushing and pulling event messages to and from an intermediary.
Problem 3.6
Discuss the similarities and dissimilarities of processes and threads.
Threads are the most basic sequence of instructions that can be run by a processor; they provide only the basic necessities for execution. Processes are any program in the process of execution. They can range from extremely complex to almost as simple as a thread, threads are also created by processes. A thread is essentially a lightweight process.
a) Multiple threads can be run at a time through multithreading, whereas a process can only have one running at a time. Context switching is also quicker, and inter-thread communication is simpler than inter-process communication.
b) Kernel support is necessary for threads due to their flexibility. The kernel can create threads instead of processes in order to keep computation time low. If a user thread performs a system call, the kernel can create a thread to execute the call instead of using a process which would be slower.
c) Thread libraries contain the code for multiple thread functions such as creating and destroying threads, message passing between threads and other necessary functions.
d) Either by providing a runnable object, or creating a subclass with an implementation of run.
e) Using thread(//thread to be run).start