Olympic Park

Uncategorized — Titus Barik on September 30, 2004 at 12:00 am

Checked out of our hotel this morning. Currently at the Sydney Olympic Park, idly surfing the Internet and catching up on weblog posts at the Sydney Superdome. Other than the fact that the Olympics were held here there’s really nothing spectacular to see. There aren’t any restaurants or shops in the area either. We’re leaving for Brisbane by plane this evening, and staying the night in the Diana Plaza Hotel. A few days of business there, and then it’s back to vacation time.

Twelfth Night

Uncategorized — Titus Barik on September 29, 2004 at 12:00 am

Morning was spent finding the Post Office, figuring out how to send international mail, and taking a ferry from Circular Quay to Manly Beach, where we spent most of the day. In the afternoon we walked the nearby Royal Botanical Gardens. It’s a beautiful park, but would be much better to explore on a day without gray skies and drizzles.

On a whim, I decided to check out the Box Office at the Opera House. It just so happened that there was one open seat for Twelfth Night, performed by the Bell Shakespeare Company at the Sydney Opera House, that evening. Spectacular, and with a student discount to boot.

City Centre

Uncategorized — Titus Barik on September 28, 2004 at 12:00 am

Light rain throughout the early part of the day made it an ideal time to head off to Sydney Olympic Park to take a first look at the ASM Conferences there. And I think I’ve finally gotten a good grasp of how the public transportation here works. The remaining of the day was spent at the City Centre, exploring Hyde Park and its Pool of Reflection, resting at The Domain, eating at the Hard Rock Cafe, and visiting the Art Gallery of New South Wales. Dad estimates that we are walking about eight miles a day.

Darling Harbour

Uncategorized — Titus Barik on September 27, 2004 at 12:00 am

Up, up, and away early in the morning for a leisurely stroll from Elizabeth St. over to Darling Harbour on the west end of Sydney. Lots to see here, including Tumbalong Park, the Chinese Garden, Chinatown, and even the University of Technology at Sydney. An inexpensive Turkish lunch at the Market City Shopping Centre was followed by a day long tour of the Powerhouse Museum. There’s a lot of cool exhibits to see here. Especially if you like steam engines. The day was concluded with a trip on the Monorail, a twenty minute ride which winds through and around the city.

Surry Hills

Uncategorized — Titus Barik on September 26, 2004 at 12:00 am

Titus here in Australia. Made it safe and sound to Sydney in the wee hours of the morning. We lost a day because of the International Date Line but will gain it back on our journey home. A taxi brought us to the Park Lodge Hotel, where we settled down for a bit and checked in before heading out and exploring the city.

The public transportation here is excellent, though there’s a fair amount of walking that still needs to be done. Took a train up from Central Station to the Circular Quay near the northeast harbor. The Sydney Harbour Bridge and Sydney Opera House are both located there. Fantastic architecture. Grabbed a quick take away bite at a nearby Indonesian restaurant on Cleveland St. Dad and I are pretty jet-lagged out so we spent the evening walking around the peaceful Moore Park that is just across the street.

G’day Mate

Uncategorized — Titus Barik on September 24, 2004 at 8:53 am

A full day of flying. Left for Sydney, Australia in the morning from the Mobile Regional Airport. The flights will go through Dallas International and Los Angeles before we arrive at our final destination. Late flight with Qantas. Had a pricey bite to eat at Dallas at an airport ManchuWok chinese place. Australia is roughly fifteen hours ahead of Los Angeles, so we end up losing a day. Nearly missed the last two flights as a result of some airport terminal confusion. Catch you on the flip side.

CyberLodge MUSH

Uncategorized — Titus Barik on September 23, 2004 at 4:33 pm

I’ve been in Mobile, Alabama the last few days with my friends and family, watching movies, preparing and planning for my upcoming travels, and so on and so forth. While thumbing through older software, that is, somewhere between the realms of Police Quest and Grim Fandango and Phantasmagoria CDs, Ryan and I re-discovered Blizzard’s classic Diablo, second perhaps only to Nethack. I’m not much for computer games, but hey, I’m on vacation. The experience flooded me with memories from my youth.

You see, somewhere buried deep in the closet of my bedroom is a pirated copy of Diablo. The original. The best. No, I didn’t get it off of USENET, or the Internet, or even a BBS. Most of you probably don’t even know what a BBS is anyway, which, oddly enough, makes me feel rather old, despite the fact that I’m only twenty something. Like The Wizard of Oz, my personal burned CD came from the land we now know as Kansas. Or something like that anyway.

The story begins sometime when I was in between middle school and high school, before my days at the Alabama School of Math and Science. The year was 1997. I was heavily into MUDs. We’re talking weekends at a time looking at an ASCII text screen through telnet, while all my friends were playing the latest glitzy expansion pack for Doom. You’ve been eaten by a grue. You can’t go north; you don’t have the key. That sort of thing. My first MUD was DragonMUD, and I still visit it in a very oscillatory way from time to time. In MUD time, I am, as of today, eight years and eight months old.

I made a lot of good friends online. I didn’t know them personally, or know their names, but it felt like I knew them just the same. In particular, there was this guy who called himself TheWizard, from where else but Kansas. And from where else but Kansas did a package arrive at my door just weeks after the release of Diablo. It was a burned CD. The case cover said:

See you on BattleNet. — TheWizard

I wonder what he’s been up to all these years. Rest in peace, CyberLodge MUSH.

LatexRender

Uncategorized — Titus Barik on September 20, 2004 at 5:51 pm

While reading a text on analog and digital networks, I realized that there was absolutely no way to convey or even summarize the information as a standard weblog article. Source code excerpts are one thing, but mathematical formulas and graphs are an entirely different domain. For such tasks, HTML is not at all suitable. Consequently, what I needed was a LaTeX system for entering formulas and having them automatically convert to images, in a very similar manner to Wikipedia. Here’s how I did it. I think you’ll be pleased with the results.

After examining several LaTeX to GIF implementations, such as mimeTex, text2gif, and LatexRender, I decided on the latter because of its rendering quality and the ability to use an actual LaTeX backend. One might think that calling LaTeX from within PHP would incur a large overhead. It does, but LatexRender cleverly avoids re-generating images by caching them with MD5.

LatexRender provides an excellent PHP script, but unfortunately, has a few minor faults and limitations for the kinds of tasks that I wanted to do. Primarily, LatexRender is suited for mathematical typesetting. First and foremost, I needed a general LaTeX interface that could be accessed and simultaneusly coexist within my Text_Wiki entry system. The package also does not generate XHTML compliant code out of the box, or in my case, Wiki code. Thankfully, these issues were not insurmountable.

To change the HTML code that is output simply requires an edit to latex.php. And to generalize the ability of LatexRender to handle any LaTeX document, edit the wrap_formula function in class.latexrender.php.

With the exception of mimeTeX, The standard technique that these programs use is to call latex, convert the resulting dvi file to postscript, and to finally convert the postscript file to an image using ImageMagick. In fact, one could manually do these steps using the following code:

latex --interaction=nonstopmode my.tex
dvips -E my.dvi -o my.ps
convert -density 120 my.ps my.gif

And we’re done. The online journal system now supports embedded LaTeX. We can do mathematical expressions, such as:

and even charts or graphs, through the use of the PStricks family of packages:

With embedded LaTeX, blogging has just become a heck of a lot more fun. The icing on the cake: LatexRender has plugins for all major CMS systems, including WordPress.

The Dining-Philosophers

Uncategorized — Titus Barik on September 18, 2004 at 1:59 pm

When learning about concurrency, the Dining-Philosophers Problem is perhaps the quintessential example that illustrates the fundamental issues involved in resource allocation and scheduling. Unfortunately, the pedagogy used in most college courses to teach this particular class of problems is less than ideal, usually focusing on trivialities such as syntax, introductory data structures, and basic thread initialization rather than the true issues at hand. Even more frustrating is the fact that students will turn in theoretically broken code that appears to work as a result of the granularity of timeslicing between threads on their operating system of choice. Fortunately, Jim Plank at the University of Tennessee provides an excellent approach to teaching this problem. His technique is a general driver that provides a foundation framework for experimenting with and benchmarking this classic synchronization problem. And for self-study, Jim offers several potential solutions, sample output data, and an analysis of each technique and its various advantages and disadvantages.

Interprocess Communication

Uncategorized — Titus Barik on September 18, 2004 at 10:52 am
26a4e5b224dfecb5da2dc5f27887c451

You’ve probably used interprocess communication, or IPC, at some point or another without even realizing it. That’s because the simplest mechanisms of IPC encompass such rudimentary functions as fork, system, the wait family, and even signal handlers such as SIGUSR1 and SIGCHLD to obtain the exit status code of a child process. In this article, I summarize Chapter 5 of ALP, and present more advanced interprocess communication techniques. As usual, I’ll skip over the material that I’m familiar with and focus more on the topics that are new to me in breadth.

Introduction to IPC

Simply, IPC is the transfer of data among processes. In this article, we discuss five modes of IPC:

  1. shared memory permits processes to communicate by simply reading or writing a memory location.
  2. mapped memory is similar to shared memory, except that it is also associated with a file on the file system.
  3. pipes permit sequential communication from one process to a related process.
  4. FIFOs are similar to pipes, but the pipe is given a name in the file system.
  5. sockets support communication, even on different computers.

The type of IPC mechanism that you will need will depend largely on the following criteria: whether you need to restrict communication to related processes, whether a process is write-only or read-only, the number of processes allowed, and whether the processes are synchronized.

Shared Memory

Shared memory allows two or more processes to access the same memory as if they all called malloc and were returned pointers to the same actual memory. Shared memory is fast and does not require a system call or entry into the kernel. However, you must perform your own memory management and synchronization, usually with the use of semaphores (semop). The steps necessary to utilize shared memory are as follows:

  1. one process allocates the segment (shmget)
  2. every other process attaches to the segment, and after finishing its use, detaches. (shmat)
  3. at some point, one process must deallocate the segment. (shmctl)

Shared memory is allocated in integral multiples of the page size. You can debug shared memory with the ipcs and ipcrm commands.

Mapped Memory

Mapped memory permits different processes to communicate using a shared file; it performs an automatic association between a file and the process memory. To map an ordinary file use mmap. A common application for mapped memory is the use of /dev/zero.

Pipes

A pipe is a communication device hat permits unidirectional communication. Data written to the write-end of the pipe is read back from the read-end. Pipes automatically synchronize between processes.

To create a pipe, invoke the pipe function. Frequently, you’ll want to create a child process and set up one end of the pipe as its standard input or standard output. For such a case, use the dup2 call. The use of pipes can also be simplified with the popen and pclose functions.

FIFOs

A first-in, first-out (FIFO) is a pipe that has a name in the file system. FIFOs are also called named pipes. You can create a FIFO programmatically using the mkfifo function, and you can access a pipe just as you would an ordinary file.

Sockets

A socket is a bidirectional communication device that can additionally be used to communicate between processes on different computers. When you create a socket, you specify three parameters: the communication style, the namespace, and the protocol.

A communication style controls how the socket treats transmitted data and specifies the number of communication partners. The communication style determines how packets are handled and addressed:

  • Connection styles guarantee delivery of all packets in the order they were sent (SOCK_STREAM).
  • Datagram styles do not guarantee delivery or arrival order. The system guarantees only best effort, so packets may disappear or arrive in a different order than shipping (SOCK_DGRAM).

The socket namespace specifies how addresses are written. In the local namespace, for example, these are ordinary file names (PF_LOCAL or PF_UNIX). In the Internet namespace, these are IP addresses (PF_INET).

Finally, the protocol specifies how the data is transmitted, such as TCP/IP, AppleTalk, and so on, to name a few.

It is easy to see that the socket is more flexible than the other communication techniques. Moreover, sockets can be accessed such like file descriptors. Sockets can be controlled with the following family of system calls: socket, closes, connect, bind, listen, and accept.

Next Page »
titus@barik.net | The Weblog of Titus Barik