Wednesday, December 31, 2008
Single Instruction Multiple Data SIMD
AMD follow with 3DNow! technology which used the floating point registers for SIMD calculation as Intel's MMX. The difference is that AMD recognized the data packed in the MM0 to MM7 register as floats. It was followed by Enhanced 3DNow! in Athlon CPU in which both Integer and Floating Point data types are supported.
In its, Pentium III CPU, Intel provided a set of 8 new registers of 128-bits size. This is enough to store 4x32-bit floating point values and this is useful in 3D calculation which deal frequently with 4x4 matrices. These new registers are called XMM0 to XMM7. Intel called the technology as Streaming SIMD Extension (SSE). Intel upgrade to SSE2 when introducing Pentium IV. With SSE2, integer values are supported as well. AMD followed suit with 3DNow! Professional, which is fully compatible to SSE2.
Saturday, December 13, 2008
LUN Masking
SAN BAU
Persistent Binding
Zoning
Multiple Paths to a Single Device
Because each device on the SAN will appear as a SCSI ID on each HBA connected tot he same, a system with multiple HBA connected to the SAN will actually think that each device on each path is a separte device. A logical layer needs to be inserted to mask these paths and present the OS with the appearance of a single SCSI connection. This is achieved by multipathing software runs on each server.
Friday, December 12, 2008
Fiber Types
Multimode fiber has 2 diameter choices. The larger (62.5-micron) core can be used to a length of 175m. The newer 50-micron core is able to extend to 500m Two diameters are used to let one to reuse older fiber optic cable that ran for say FDDI network.
Single-mode fiber has a much thinner core for transmission of 1 mode up to 10 km.
Optical Fibrer Control (OFC)
FCAL Address Selection
Each node then continues to transmit the loop initialization select master (LISM) frame to select a master. If the loop is also connected to a fabric (via FL port), the fabric port becomes the loop master. If not, the port with the lowest port name is chosen as loop master.
The next step is every node must select an AL_PA. The loop master sends a loop initialization select AL_PA (LISA) frame around the loop. Each L port on the loop selects a free AL_PA in the frame and marks that AL_PA used. It then forwards the frame to the next L port in the loop. In case of reinitialization, the node will attempt to select the previous AL_PA whenever possible.
Once the LISA returns to the master, it sends the CLS (close) grame to notify all nodes that the initialization process has completed.
FCAL Arbitration Process
When more than 1 nodes are arbitrating sumultaneously, the ARB frame with lowest AL_PA wins the arbitration.
Nodes that won arbitratuion can transmit until it finishes. It is not the same as token ring which transmission is limited to a fixed time period. To allow nodes with lower priority to transmit, a port that wins arbitration will set its access variable to 0 which will inhibit arbitration request. This is called fairness algorithm.
Once all talkers are allowed to transmit, the last one will place an IDLE frame to the loop. This casued every nodes to set its access variable back to 1 and the process start over again.
Difference between FCAL and Fabric
Arbitrated Loop
A better configuration is star layout. The connectors do not need to be split. A hub will make sure the transmit and receive ends are matched up. A manged hub can also prune the node in the event of a failure.
Fabric Topology in FC
Point-to-point FC
FC Addressing
Other FC Port Types
NL Port is a node port with arbitrated loop capabilities. A NL Port can connect to another node, to a switch or to an arbitrated loop.
FL Ports is a fabric port with arbitrated loop capabilities. The switch port can connect to either a node or to an arbitrated loop.
G Port is a generic port on a switch which can act as E Port, F port or a FL port depending on what connects to it.
Fibre Channel Basic Ports
F Port - fabric port which is found only on a switch. F port can only communicate with a N port.
E port is an expansion port on a switch that connects to another switch.
Media for FC
Five Layers of FC
FC-3 (Common Services) is used by applications requiring more than one port, such as striping.
FC-3 (Framing) is similar to MAC layer in OSI. It defines how data from upper level applications is slit into frames for transport over the lower layers.
FC-1 and FC-0 are similar to physical layer in OSI. FC-1 (Ordered Set) defines how frames are encoded and decoded for transport across those media types. FC-0 (Physical) defines the various media types that can carry FC data.
Fiber or Fibre?
Sunday, November 9, 2008
Tomcat
- Catalina is the servlet container
- Jasper parses and translates JSP to Java servlet and then compile into Java class to be managed in Catalina
Deployment descriptor tells the container details about the servlet. It also provide function such as hiding the internal directory structure by specifying an alternate mapping. The mapping also enable the change of the internal directory without affecting the external access path.
HTTP Post
HTTP 200 or 204 = respond with an acknowledgement and provide no other data
HTTP 201 = indicate the entity has been created and provide more information about the creation
The latter case makes POST appear like a GET.
Static or dynamic GET responses can be cached with uses of HTTP control header such as If-Modified. HTTP 1.1 uses either date or tag (Etag) to validate content from cache. POST is considered as a mutable operation on the server. HTTP methods PUT, DELETE and POST must cause a cache to invalidate its entry. Thus POST is less efficient comparing to GET.
J2EE
EJB has built-in support for many low level technologies to enhance the scalability of server side logic. Comparing to client side logic (fat client), scalability is a challenge for server-side logic. The technologies include object persistence, transaction management and location transparency.
Under the J2EE model, EJBs are distributed objects managed by containers. The container provides surrogates (EJBObject) that interact with individual bean instances, on behalf of the client. The containers manage the lifecycle of its bean instances (creation and destruction). A client communicates with an EJBObject. The EJBObject acts as a middleman in the communication between client and bean. Its assignment to a bean instance is coordinated by the container. Client interacts with EJBs consists of the following steps:
1.A handle to an EJBObject is acquired by client.
2.Business methods of that object are called by client as needed.
3.After use, the client relinquishes the handle to the EJBObject.
The home interface is used for step 1 and 3. A local or remote interface for step 2.
The home interface provides factory-like services to create, destruct and find the EJB requested. The remote or local interfaces provide a clean API to application logics (business methods) encapsulated by the bean. The local interface is meant to be accessed by clients located on the same host as the bean.
Bean provides call-back method for the container to manage its lifecycle:
Creation: When the client demands but no available instance exists, the container must instantiate a new instance.
Destruction: Bean instances can be periodically garbage-collected.
Activation: A lite form of creation. Bean instances are pooled for performance reason. Container draw from the pool to fulfil a request.
Passivation: A lite form of destruction. A bean instance is returned to the pool.
There are 3 basic types of EJB:
Session beans are associated with specific business transaction, particularly one requested during an interactive session.
Message-driven beans are also associated with specific business action, particularly one that is necessary for application integration or batch processing.
Entity beans are associated with an application object that requires persistent storage.
Session beans are either stateful or stateless. Stateful session bean maintain state during communication with a client. They retain the values of their instance variables between client requests. It is important for the client to interact with the same bean. Theoretically, there should be as many stateful session beans as there are concurrent sessions. According to J2EE spec, stateful session beans may be periodically written to persistent storage.
Stateless session beans do not maintain state between requests and therefore can be used to process requests from any client. They are more scalable. However, session bean often requires state management. The state must be stored somewhere: cookies, URL rewrite, in server-side memory or in database.
Entity beans correspond to application objects that are meant to be persistent – contain potentially valuable information across sessions. It may be useful to think of entity bean as tables or relations in a relational database. They contains attributes, foreigh and primary keys to enforce entity integrity. Entity beans can be shared by multiple clients. Entity bean can relate to each other.
Entity bean's persustence can be either container managed or bean managed. BMP is there because J2EE implementation cannot know everything. The main advantages to CMP are simplicity and portability. You do not need to code SQL. You just need to provide a few methods that meet the requirements of your bean contract and specify some key information in the deployment descriptor. J2EE does the rest. As a result, your beans consist of much less Java code.
CMP method and mechanism for persistence vary between vendors. This means that CMP could be implemented by writing serializable Java object to the filesystem or by tight integration with a high performance database.
Since entity beans have relationships with other entity beans, there is a considerable likelihood that they'll be chatty in nature. Just as navigating a relational data model can result in many queries to the database, navigating through entity EJB objects can result in substantial cross-object communication – marshalling and network communication.
EJB 2.0 addresses this by offering a local model. For entity bean that are only called by other entity bean but not directly from client, maintaining a remote interface is a waste. EJB 2.0 develops the bean with a local interface and making it a local object.
The advantages are (1) more efficient argument marshalling – pass by reference rather than by value, (2) more flexibility in terms of security enforcement.
Another CMP feature in EJB 2.0 is container-managed relationships, equivalent to RI in database. Finally, CMP includes dependent objects, which can be thought of as extensions to entity bean. Dependent objects allow complex CMP fields to be represented in a separate class. This is a way of breaking up a more complex object into distinct parts.
BMP results in more time-consuming and complex development responsibilities. It also implies maintenance overhead for code and changes in data model. For performance, BMP may be more desirable but must be done right.
Session bean is unique on the method of invocation. Clients do not interact by calling a remote Java method. Instead, clients send messages via JMS and result in execution of an onMessage() bean function.
Interactive web page experience
Microsoft has introduced the concept of remote scripting (MSRS) to overcome this limitation. It allow developer to interact with the server asynchronously. For example, user can select the drop down list and causing a script to run at the server to download the value for the drop down list, without a complete page refresh. MSRS works with Microsoft technology only and requires Java.
Brent Ashley developed JSRS (JavaScript Remote Scripting) using client-side JavaScript library and DHTML to make asynchronous call to server. Other people uses IFRAME to reload only part of the page or make hidden call to the server.
AJAX is another solution. It is not new. It is the “newest” technology related to XMLHttpRequest object (XHR) which has been around since IE5 (1999) as an ActiveX control. XHR since then has also implemented in other browser such as Mozilla and Safari. It is even covered in a W3C standard: DOM Level 3 Load and Save Specification. AJAX is a client-side approach and can interact with J2EE, .Net, PHP, Ruby and CGI scripts. In other words, it is server-agnostic.
Load and Save is the culmination of an effort that began in 1997 as a way to solve the incompatibilities in the browsers. DOM Level 1 was finished in 1998 giving HTML 4.0 and XML 1.0. DOM Level 2 completed in 200 giving CSS. Load and Save gives Web developer a common, platform-independent API to access and modify the DOM.
DOM is based on a concept from OMG. DOM defines the data and structure on a page. DOM give you a standard way to interact with your documents. By modifying the structure of a web page, you dynamically change the display, resulted in giving a rich client interactive environment to the user. For example, when the user client on the search button, your page makes an aynchronous call via XHR to do the search. After the server returns the search result, you use DOM call to modify the web page to display the search result (for example, in the form of a table). The broswer adjust the display and thus give a interactive sensation to the user.
Saturday, November 1, 2008
What is Marshalling
Saturday, October 25, 2008
What is asynchronous logic?
However, to build a state machine (e.g. computer), the change of state must be synchronized with some master signal (clock).
Color
Saturation (Chroma) is the strength or purity of the color. It is simply the amount of white in the color. Brightness (Value) is the lightness or darkness of the color. It is determined by the amount of black in the color.
Combination of hue, saturation and brightness create infinite number of color that we see in the world.
Sunday, October 5, 2008
What is a pipe?
A pipe is typically used by a parent process to communicate with its child. It is achieve by creating the pipe before the fork call. The file dscriptors of the pipe will be then be inherited by the child process. Read/write to the pipe is not atomic. In other words, the read could return partial data if the read and write call is in a race condition.
The pipe "|" used in shell (e.g. ls -al | sort -n 4) can be implemented using a combination of pipe and I/O redirection. The pipe-read file descriptor replaces the stdin for one process, and the pipe-write file descriptor replaces the stdout for the second process.
Saturday, October 4, 2008
How is I/O redirection realized?
The command "cat > test.txt" will echo terminal input into a text file instead of stdout.
I/O redirection is implemented using the dup2 function. dup2 copies one file descriptor to another in the file descriptor table. To realize redirection in the cat command above, first open test.txt which result in the creation of a new file descriptor in the table. Then use dup2 to copy this new entry to file descriptor 2 (stdout). After the call, stdout is now pointing to test.txt. When cat writes to stdout, the data will be written to test.txt.
What is a file pointer?
The ISO C standard I/O functions use file pointer instead of file descriptor.
File pointer is the address of a FILE structure which in turn contains the file descriptor number. The FILE structure also contains the buffer used in buffered I/O. Data will be written out from the buffer to the destination devices when the buffer is filled up (for disk I/O) or when the new line character is encountered (for terminal I/O). The I/O subsystem performs the write using file descriptor.
The fflush call force-writes the buffer out immediately.
What is a file descriptor?
A file descriptor is an integer corresponding to the index into the file descriptor table. The file descriptor table exists in user address space. Each process has its own copy of the file descriptor table. Direct access to the table is not possible except via functions that uses file descriptor.
File descriptor table entry points to am entry in the system file table. The system file table exists in the kernal space and the same table is shared by all processes. Each entry contain the current offset, access mode and number of file descriptor pointing to it. Each system table entry points to an entry in the in-memory inode table which represents the physical file. Similarly, more than one entry of the system table may point to the same in-memory inode table entry.
Friday, October 3, 2008
What is the benefit of representing device as file?
Devices are represented as special files in UNIX under /dev. Representing devices as files simplifies the programming model such that all devices can be controlled consistently by 5 system calls - open, close, read, write and ioctl.
Block devices are those that have characteristics similar to disk. They typically allow random access. Data are access in unit of blocks.
On the other hands, charcter devices have characteristics similar to terminal. Access is sequential and data is represented as a stream of bytes.
Difference between stdout and stderr
stdout and stderr is defaulted to the console. It means both error messages and normal output will be shown on the same device. Why do we differentiate stdout and stderr in the first place?
Output to stdout is buffered. In other words, output may take some time before it will appear in the destination device (console typically). In contrast, stderr is unbuffered. It means output will appear in the destination device immediately after the write call. That's why error message should be written to stderr instead of stdout.
Why are there zombie process?
Terminated process which has not been waited for becomes a zombie process. If the parent terminates without executing the wait call for its child, the child zombie process becomes an orphan process. Orphan process will be adopted by the init process (PID=1). init will call wait periodically and this is the mechanism UNIX uses to clean up zombie processes.