Monday, March 17, 2008

海天使

Clione Limacina 無殼科具類生物,成年長3-4厘米。攝於日本北海道網走流冰館。

Wednesday, March 12, 2008

BSD filesystem services

4.4BSD
For user processes, all I/O is done through descriptors. The file descriptor is used by the kernel to index into the descriptor table for the current process to locate a file entry (or file structure). The information is kept in the filedesc structure which is a substructure of the process structure for process.

File descriptor (user process) -->
descriptor table (filedesc process substructure) -->
file entry (kernel list)-->
  • vnode
  • interprocess communication
  • virtual memory
The file entry provides a file type and a pointer to an underlying object for the descriptor. For data files, the file entry points to a vnode structure that references a substructure containing the filesystem-specific information. The 4.4BSD file entry may also reference a socket, instead of a file. Socket has a different file type, and the file entry points to a system block that is used in doing interprocess communication.

Special files do not have data blocks allocated on the disk; they are handled by the special-device filesystem that calls appropriate drivers to handle I/O for them.

The virtual memory system supports the mapping of files into a process's address space. Here, the file descriptor must reference a vnode that will be mapped into the user's address space, either partially or completely.

inode
In 4.3BSD, the file entries directly referenced the local filesystem inode. An index node, or inode, is a data structure that describes the contents of a file:
  • The type and access mode for the file
  • The file's owner
  • The group-access identifier
  • The time that the file was most recently read and written
  • The time that the inode was most recently updated by the system
  • The size of the file in bytes
  • The number of physical blocks used by the file (including blocks used to hold indirect pointers)
  • The number of references to the file
  • The flags that describe characteristics of the file
  • The generation number of the file (a unique number selected to be the approximate creation time of the file and assigned to the inode each time that the latter is allocated to a new file; the generation of number is used by NFS to detect references to deleted files)
Note: Filenames are maintained in directories, rather than in inodes, because a file may have many names, or links, and the name of a file may be large (up to 255 bytes in length).

The structure of an inode:
  • mode
  • owners(2)
  • timestamps(3)
  • size
  • direct blocks --> data
  • single indirect
  • double indirect
  • triple indirect
  • block count
  • reference count
  • flags
  • generation number

The inode contains an array of pointers to the blocks in the file. The system convert from a logical block number to a physical sector number by indexing into the array using the logical block number. Since inodes are statically allocated and most files are small, so the array of pointers must be small for efficient use of space. The first 12 array entries are allocated in the inode itself. For typical filesystems, this allows the first 48 or 96 Kbyte of data to be located directly via a simple indexed lookup.

vnode
Sun Microsystems implemented the first virtual file system by adding, VFS layer, a new object-oriented layer between the file file entry and the inode. A vnode used by a local filesystem would refer to an inode. A vnode used by a remote filesystem would refer to a protocol control block that described the location and naming information necessary to access the remote file. Unlike the original Sun Microsystems vnode implementation, 4.4BSD allows dynamic addition of vnode operations at system boot time. As part of the booting process, each filesystem registers the set of vnode operations that is able to support. The kernel then builds a table that lists the union of all operations supported by any filesystem. From that table, it builds an operations vector for each filesystem. Moreover, unlike most vendor's vnode implementation, which have a fixed number of vnodes allocated to each filesystem type, the 4.4BSD kernel keeps a single systemwide collection of vnodes. The benefit of having a single global vnode table is that the kernel memory dedicated to vnodes is used more efficiently than when several filesystem-specific collections of vnodes are used. For example, consider when the user application shifting from local filesystem to network filesystem.

In 4.3BSD, the local filesystem code provided both the semantics of the hierarchical filesystem naming and the details of the on-disk storage management. To enable experimentation with other disk-storage techniques without having to reproduce the entire naming semantics, 4.4BSD splits the naming and storage code into separate modules. At the vnode layer, there are a set of operations defined for hierarchical filesystem operations and a separate set of operations defined for storage of variable-sized objects using a flat name space. About 60% of the traditional filesystem code became the name-space management, and the remaining 40% became the code implementing the on-disk file storage.

Buffer Cache
Another important service provided by the filesystem-independent layer is the management of kernel's buffer space. The task of the buffer cache is two-fold. One is to manage the memory that buffers data being transferred to and from the disk or network. The other, more important, is to act as a cache of recently used blocks. The buffer is composed of two parts. The first part is the buffer header, which contains information used to find the buffer and to describe the buffer's contents. The content information includes:
  • hash link
  • free-list link
  • flags (buffer status)
  • vnode pointer
  • file offset
  • byte count
  • buffer size
  • buffer pointer --> buffer contents MAXBSIZE (64 Kbyte)
The second part is the actual buffer contents. Rather than the header being prepended to the data area of the buffer, as is done with mbufs, the data areas are maintained separately. The buffer size is always at least as big as the data block that the buffer contains. Data are maintained separately from the header to allow easy manipulation of buffer sizes via the page-mapping hardware. In this case, there is no need to set the header on a page or to check the collision of the other header.

Buffer management
Because the requested block already resides in the buffer cache, on a typical 4.4BSD system, over 85% of the the implied disk or network transfers can be skipped. Depending on the available memory, a system is configured with from 100 to 1000 buffers. The sizes of buffer requests from a filesystem range from 512 bytes up to 65,536 bytes. While the address space is not fully populated with physical memory, in order to allow the system to adapt efficiently to the changing needs of buffers' sizes and numbers, the kernel allocates to each buffer MAXBSIZE bytes of virtual memory. For example, initially each buffer is assigned 4096 bytes of physical memory. As a smaller buffers are allocated, they give up their unused physical memory to buffers that need to hold more than 4096 bytes.

In earlier versions of BSD and in most other versions of UNIX, buffers were identified by their physical disk block number. 4.4BSD changes this convention to identify buffers by their logical block number within the file. For filesystems such as NFS, only a logical block number can be used as there is no way for the local client to compute the physical block address of a logical file on the server. Moreover, the savings are considerable for a local filesystem where the computation may require traversing up to three indirect blocks. The drawback to using a logical-address cache is that it is difficult to detect aliases for a block belonging to a local file and the same block accessed through the block device disk whose logical-block address is the same as the physical-block address.

Stackable filesystems
The early vnode interface was simply an object-oriented interface to an underlying filesystem. The vnode interfaces implemented vnode operations as indirect function calls. As the demand grew for new filesystem features, the stacking ideas was implemented in the 4.4BSD system. The bottom of a vnode stack tends to be a disk-based filesystem, whereas the layers used above it typically transform their arguments and pass on those arguments to a lower layer. Stacking uses the mount command to create new layers. The mount command pushes a new layer onto a vnode stack.

When a file access occurs to a vnode in the stack, that vnode has several options:
  • Do the requested operations and return a result
  • Pass the operation without change to the next-layer vnode on the stack. When the operation returns from lower vnode, it may modify the results, or simply return them.
  • Modify the operands provided with the request, then pass it to the next-lower vnode. When the operation returns from the lower vnode, it may modify the results, or simply return them.
If an operation is passed to the bottom of the stack without any layer taking action on it, then the interface will return the error "operation not supported."

In order to implement the stacking (bypass of operations to lower layers and adding of new operations into the system at boot time), kernel has placed the vnode operation name and its arguments into an argument structure. The latter is then passed as a single parameter to the vnode operation. Thus, all calls on a vnode operation will always have exactly one parameter, which is the pointer to the argument structure. If the vnode operation is unknown, then the generic bypass routine can call the same operation in the next-layer, passing the operation the same argument structure that is received. In addition, the first argument of every operation is a pointer to the vnode operation description. This description provides to a bypass routine the information about the operation, including the operation's name and the location of the operation's parameters.

3-0-0 Puzzles

Particles and Antiparticles
Associated with any particle is the corresponding antiparticle. Theoretically, the existence of antiparticles has been shown to be a consequence of the theory of quantum mechanics combined with Einstein's theory of relativity. It is known under the name CPT theorem. An antiparticle can be defined by the fact that if taken together with the particle one obtains something that has no properties except energy. No charge, no spin, nothing.

A particle may be equal to its antiparticle. An example of such a "self-conjugate" particle is the photon. Another example is the π0 which is a spinless bound state of a quark and an antiquark. Not only elementary particles have antiparticles, but also non-elementary particles, such as the proton, have their anti-companion. They are simply made up from the corresponding antiparticles.

The W+ and W- are each other’s antiparticles. The photon and the Z0 are their own antiparticles, and the antiparticle of any gluon is simple another one of the gluons. For example, the anti-version of the red-antiblue gluon is the blue-antired gluon. The graviton (zero mass) is its own antiparticle. This is the only known spin 2 particle. Although the gravitational field is of course well known, it has not been observed directly.

Neutrino
If the particle has no mass and moves with the speed of light then “handedness” is not a relative statement. You have particles that are always left-handed. If it is massless than the neutrino is such a particle. The interactions are such that always a left-handed particle is emitted, i.e. the spin is always counter-clockwise in the direction of motion. The antiparticle is always right-handed. The spin flips direction when passing from particle to antiparticle.

If you see a particle decaying into a neutrino / antineutrino pair (flying off in opposite directions) then you know that the particle has spin 1. Thinking in an opposite way, when you collide a neutrino with an antineutrino in the opposite direction the spins point in the same direction. There is actually such a spin 1 particle, called the Z0. It indeed decays some of the time into a neutrino-antineutrino pair. These statements are subject to change if it is found that neutrino have mass, and thus do not move at the speed of light. In that case you could, by going faster than the neutrino, turn a left-handed neutrino into a right-handed one.

Despite the fact that neutrinos are neutral the antineutrinos are different from the neutrinos: they are not their own antiparticle. They have different handedness. Furthermore, neutrinos have lepton number 1, and antineutrinos have lepton number -1, which means that some reactions are possible with neutrinos but not with antineutrinos and vice versa.

Elementary puzzles
Color of three
The greatest puzzle of elementary particle physics today is why are three families? Having only three families and no more makes it virtually impossible to see them as bound states. A further problem is presented by the three neutrinos. For all we know their masses are zero (or very nearly so). The difficulty is that no one knows of any way to have a bound state such that the mass of that state is zero. Up to now most people thought that neutrinos are massless, but certain recent experimental facts suggest that neutrinos have (small) masses. If so these masses are less than the known limits.

Masses
Here is another major problem of elementary particle physics. Where do all these masses come from? Why is the top-quark so incredibly heavy? Why are neutrinos massless (if they were)?

Spin 0 - Higgs boson
Experimentally we have never encountered any elementary particle that has spin zero. There is a hypothetical particle, the Higgs boson, that supposedly has spin zero, but this particle has not been observed so far.

Tuesday, March 11, 2008

Open Interest

There is no limit to the number of buy and sell contracts in the futures, options, and forwards markets. An open interest constitutes a buyer and seller of a future contract, the number of outstanding depends exclusively on demands in the market. Daily statistics are kept on open interest in the futures and options exchanges.



CBOT - Chicago Board of Trade

Technicians (of Technical Analysis) gauge the quality of a market move by comparing daily changes in open interest in the futures market with the direction of the futures price. A 10% change in open interest deserves serious attention, while 25% change often gives major trading messages.

Open interest trading rules
When open interest rises
  • During a price rally - a bullish signal. New longs have entered the market. It is safe to add to long positions.
  • While futures prices fall - a bearish signal. New short positions have been established. It is safe to sell short.
  • While futures prices are in a trading range - a bearish signal. Commercial hedgers are more likely to sell short than speculators.

When open interest falls
  • During a price rally - a bearish signal. Rally is due to short covering rather than new long positions. So sell and get ready to sell short because participants are getting out of the market.
  • During a decline - a bullish signal. It suggest that the sell off was due to long liquidations that eventually will be exhausted. So cover shorts and get ready to buy.
  • In a trading range - a bullish signal. It identifies short covering by major commercial interests, particularly if open interest is falling sharply.

When open interest is flat
  • During a rally - a signal to tighten stops on long positions and avoid new buying
  • During a decline - best to tighten stops on short positions
  • In a trading range - this does not contribute any new information

Monday, March 10, 2008

Missing Mass

According to the Standard Model, except gravity, forces that govern the matters and particles are summarized in the diagram at below.



The model does not explain where is the mass come from and there are also eighteen numerical parameters that must be put "by hand" into the theory.

We are looking forward to see the results coming from the Large Hadron Collider (LHC). When activated, it is theorized that the collider will produce the Higgs boson. The Higgs boson may help to explain how elementary particles acquire properties such as mass. The project also planned to study various interesting phenomena such as strangelets, micro black holes, magnetic monopoles, and supersymmetric particles.

Wednesday, March 5, 2008

Dynamics and Thermodynamics of Hurricane

Typhoon is a typical storm in the region of the Indian or western Pacific oceans. Hurricane is a storm with a violent wind, in particular a tropical cyclone in the Caribbean. Both of them form over hot oceans at 10 - 30 degree of latitude. The Coriolis force (resultant force between the centrifugal force and gravitational force of earth) in this region drives the wind toward the eye. The result is the angular momentum associated with the earth's rotation is concentrated into angular momentum associated with hurricane winds. The cyclone grow with the energy gained from expansion and compression of vapor over the sea.

The hurricane's eye is formed when the centrifugal force of the air equal the inward-directed pressure gradient force. The place where the forces balanced each other is called the eye wall. The pressure inside the eye is the lowest and increase rapidly outside the wall. By the simplified model of pressure distribution, the maximum tangential winds are found at the outer side of the eye which is twice the radius of the eye.

Because the mechanical energy of the hurricane is come from the heat of the ocean, it can analogous to Carnot heat engines. A Carnot process is a closed cycle consists two expansion phases and two compression phases.
  1. The air in the boundary layer spirals in from the place over the sea-level toward the eye wall isothermally (constant temperature ~26-28 C). Pressure decreases to ~P=90 kPa as the air approaches the low-pressure eye. Evaporation from the sea surface causes the increase of entropy. It is the major source of energy for the storm. (isothermal expansion)
  2. Inside the wall, vertical air flow rises moist adiabatically to the top of the eye wall (~15km above sea surface). At the top of the wall, temperature drops to -18C and pressure is as low as 25 kPa. In this adiabatic process, entropy conserves because air expand. (adiabatic expansion)
  3. Once the cloudy air reaches the top, it spirals outward at constant altitude (travel to the edge of the hurricane ~700 km). There is a pressure gradient between the eye (25 kPa) and the atmosphere (20 kPa). During this high-altitude outflow, air rapidly loses heat due to infrared radiation, causing its temperature to decrease from -18 C to -83 C (away from the eye wall). Entropy decrease because the cooling converts more water vapor into precipitation. (isothermal compression) For the temperature of the core, see the note below.
  4. Finally, at the edge of the hurricane, air subsides dry adiabatically. Temperature increases adiabatically to 28 C, due to the compression as air descends into higher pressure (normal level). This dry adiabatic process preserves entropy. (adiabatic compression)
The gain of entropy at one temperature and loss at a different temperature allows the Carnot engine to produce mechanical energy.

Note:
Because of the latent heating, the centre of hurricane is warmer than the surrounding. Latent heat warms the whole depth of the hurricane core. While the eye might be only ~2 C warmer near the sea surface, it can be 10 C warmer at 12 km altitude. Because warm layers of air have greater pressure, it will spread out horizontally at the top of the hurricane.

Summary
The angular momentum of the winds is maintained by the Coriolis force of the earth. If it exist long enough then boundary-layer air is drawn toward the eye. The traveling air carries quite amount of water vapor due to evaporation as it blows over the increasingly rough sea. The cyclonically-spiraling air (with heavy moist) reaches the eye wall and rises to produce heavy rain. The warm water vapor is the main source of energy for the hurricane. At the top of the hurricane, the rising air spreads out, creating anticyclonic outflow that is observed by satellite. The outflow eventually subsides back toward the sea surface.