Department
of Computer Scienceg++ -o server server.o convert.o misc.o -lsocket -lnsl
Do "man socket", "man -s3SOCKET accept", etc to get Solaris documentation on the socket library functions you are supposed to use.
| Instructor: | Prof. S. Chaiken
LI-67A, 442-4282 sdc@cs.albany.edu |
M 11:30AM-12:30PM; W, F: 11:30AM-1:00PM and by appointment or if not busy |
| Teaching Assistant: | Jing Qian
LI-96P, 442-4285 jq7581@albany.edu |
T, Th 12:00-2:30PM
and by appointment |
Textbooks:
HOMEWORK 7: Due in 9 days (Nov. 5) the 5 problems from Chapter 6 of OSCJ: (6.3), (6.4), (6.5), (6.7) and (6.9).
Read as much as you can of Chapter 11 of ULK. Write an explanation of lazy compared to direct invocation of the scheduler and the role of the "need_resched" field of a task_struct in this explanation.
Look up under http://lxr.linux.no/source/?v=2.6.0 (1) The Documentation of the scheduler (first browse the Documentation directory), and (2) the schedule() function coded in kernel/schedule.c (use your browser's "find" operation). Write a short written report that describes (a) a few lines of code that helps recompute priorities, (b) the line where the next task chosen by the scheduler is recorded in a variable, and (c) the line where the kernel actually decides whether or not to make a context switch.
It may also help to read about Linux 2.6.0 scheduler innovations from http://www-106.ibm.com/developerworks/linux/library/l-inside.html
Handout: Guidelines and Rules for Programming Project 1 and others (.pdf) Handout: How to Use turnin to submit project work electronically (.pdf) Each C/C++ automatic variable is allocated in the execution stack of the current process. The memory belonging to one process is typically composed of regions with disjoint intervals of addresses. Each region is called a segment. One segment is used to store the stack, another for static variable, yet another for program (machine language) code. Intro. to using the read() system call. Pitfalls and directions for coding the address of the destination variable in argument 2 and the maximum number of bytes to read in argument 3. The return value indicates the number of characters actually read; the return value of 0 indicates "end of file" which means there is no more data. See Haviland chap. 1-2. One view of what a computer does is the interactions of I/O devices with users or other things in the environment. (cute cartoon of an elephant, see also Bovet and Cesati's Basic OS Concepts section, p.8, for a more serious styled explanation.). Another view is the loading and running of programs. The computer has randomly addressible memory to store the program code (in machine language) and CPU composed of an arithmetic/logic unit plus registersincluding a stack pointer and a program counter. Among the (assembly language) instructions from MIPS/spim simulator of Albany's CSI333, the syscall instruction is different because it does I/O instead of just manipulating memory and data values. In real systems, system call type instructions act very differently from ordinary instructions: A system call instruction causes an event in the CPU called (variously, according to vendor) a trap, exception, interrupt, or fault. What and where is the operating system kernel. When a trap, etc. occurs, the data in the registers is copied to a part of memory belonging to the kernel, the interpretation of addresses changes so kernel code and data is now referred to by addresses, and the computer begins to run code from the kernel. The kernel's scheduler (a software system) decides which process to return to when the kernel code finishes. Timesharing is implemented by a hardware clock generating interrupts frequently, which enables the kernel to reschedule processes in an interleaved fashion. The clock interrupts enable the kernel to run interleaved with the current process so it can determine when to run the scheduler. The maximum period of time that can elapse between activations of the scheduler is called the quantum. The quantum is generally around 0.1 to 0.01 second (these figures are corrections from what I said in class.)
- it makes a blocking system call, or
- it makes a special system call to voluntarily "yield" the CPU so other ready processes might run.
- Today, users, more precisely, processes running client software, connect to servers across networks to obtain computer service. "Long term scheduling" is performed by server subsystems that manages connections or do load balancing among multiple server hosts.
- I/O bound, CPU bound, Interactive, prioritization: These are characteristics of a process that a schedule might use in its algorithmfor deciding which process to run.
#include <iostream>
using namespace std;
int main()
{
int X;
cin >> X; //BLOCKS until input is typed in.// This means cin.operator>>(X);
// This FUNCTION CALL STATEMENT doesn't finish
// UNTIL input data is stored in X.
// (assuming a corrctly formatted decimal integer was typed.)cout << "your number multiplied by 52 equals " << X*52 << "." << endl;
return 0;
}
- HOMEWORK: On ITS Solaris, run the command "ps -Afl | less", then find out the significance of the one-letter process state codes by finding that info in the output of "man ps". Then do ps -Afl again now that you know the significance of some of the columns.
- Java Sources
- Buffer.java--INTERFACE SPECIFICATION for any "Buffer"
- Factory.java--Execution of Java application starts HERE. Note the main() method--it is like main() in C/C++.
- BoundedBuffer.java--The fixed size array implementation with the Buffer interface.
- Producer.java
- Consumer.java
- SleepUtilities.java--Used to implement the sample producer and consumer types of programs.
- BoundedBuffer.java--The fixed size array implementation with the Buffer interface.
- Data Structures after memory allocation but before constructors have been run(.png) (.pdf) (.ps)
- Data Structures after all the constructors have been run(.png) (.pdf)(.ps)
- Result: The Producer and Consumer objects SHARE the common BounderBuffer object..
- We "talked through" some of the Java code and what it did...Homework: figure out how it all works completely!
- We also introduced some subtle Java fundamentals in terms of many similarities and a few differences with C and C++: interfaces (abstract classes), classes, how Java references are like C/C++ pointers, mentioned inheritance, ... Java Thread class and Runnable interface: what they mean in terms of the Producer-Consumer case study in Java.
Threads, (like system calls, virtual memory, files, etc.) are features implemented by the operating environment. (The operating environment includes (1) the kernel (sometimes called operating system) (2) system libraries (such as pthreads) (3) user interface and "user level" application runtime support systems (like shells, window systems, dynamic linkers, virtual machine interpreters like java, etc.) (4) utility software (text editors, web browsers, etc.), and sometimes (5) software building tools, such as compilers, assemblers, Windows resource file editors, linkers, etc.
CSI400 students need to know WHAT ARE THE threads that the kernel implements.
The boundary between the kernel and each process is the system call interface plus the process's virtual memory. The kernel as another boundary that separates it from the hardware.
Read an intro. to this in Chapter 5 of OSCJ. But Section 5.7 is most important for you now since it explains Java threads, and we will use Java threads to illustrate some fundamentals.
- Sequence Diagrams See pages 102-105 of this document
- Unified Modeling Language(UML)--http://www.omg.org/uml/
Special instructions that the Instruction Set Architecture (synonym: Machine Language Specification, which is what an assembly language programmer must know to be able to competently write programs for a particular "brand" of CPU) that execute atomically even though they make multiple memory accesses. The hardware is built so concurrent operation of other CPUs and direct memory access I/O devices or controllers will not interfere with them.
mutex_unlock:
MOVE MUTEX,#0
RETURN
Virtualization: A system implemented part interacts with its client part so the client gets services that behave as if the system implemented a possibly different model.
Example: Virtual memory and timesharing a CPU: Each process has the illusion that it has the exclusive use of the computer.
Given a memory size (say 100 bytes) and such a sequence (with block sizes of 10, 20, 30, ..., 70, 80, etc) demonstrate each of the following allocation algorithms: (1) First Fit (2) Best Fit (3) Worst Fit. Distinguish an allocation failure due to there really not being enough free memory from an allocation failure due to external fragmentation.
Will there always be a deadlock in this situation? Why or why not?
Then, show how to reorder the operation sequence in one thread in a way to guarantee there cannot be a deadlock.