Home > Enterprise Linux Tips > Administrator > Running Mozilla processes on Linux
Enterprise Linux Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ADMINISTRATOR

Running Mozilla processes on Linux


Nigel McFarlane
09.22.2004
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


If you're a close observer of such things, you might notice that running a Mozilla browser results in more than one process or thread being started, and that the number of processes grows and shrinks. A closer look at that is an opportunity to study both Mozilla and process creation on Linux. That's the subject of this tip.

In order to begin, the magic commands you need are "ps," "watch" and "lsof." Start Mozilla or Firefox as you normally would, and then turn to the command line, say in a Gnome Terminal or an xterm. From there, try:

ps -Hfu$LOGNAME

The resulting output should show a neat hierarchy of half a dozen processes all with "mozilla" in their names (or "firefox" as the case may be).

If you use this longer version:

watch ps -Hfu$LOGNAME

then the same display results, but it's updated every two seconds. This updating display is a good way to see how the set of mozilla processes changes over time. You can start this program before Mozilla starts, too.

The hierarchy of processes shown seems to say that there's a lot going on inside Mozilla, but it's not as complicated as it seems.

The topmost Mozilla process is just a shell script named "mozilla" or "firefox". For the convenience of distribution providers, admin people and installers, some twiddling can be done in here if necessary. This script ultimately calls another, which is always called run-mozilla.sh. This second script sets up the runtime environment for the Mozilla Platform, including some options that make debugging easier for developers. Finally, the platform itself is launched: usually a binary named mozilla-bin or firefox-bin.

The mozilla-bin (or firefox-bin) binary appears several times in the ps list. That's because there are several separate threads of control running inside the Mozilla platform. That is responsible for the number of processes at work. Two of the most important threads are the "main UI thread," responsible for user input and output via X11 and Gtk, and the JavaScript interpreter thread. There are, however, other threads as well.

If the user attempts to display two different Web sites in two different windows, then two separate Internet DNS lookups are required. Mozilla does simultaneous DNS lookup using a thread for each lookup. Such threads hang around for a bit afterwards in case you need them again; they don't die straightaway. One of these DNS threads is supplied at startup time in order to fetch the browser home page. That's why the number of Mozilla processes can reduce slightly after start up if the browser stands idle.

Two other examples of temporary processes are those of timers and Java. If any JavaScript code uses timer mechanisms like setTimeout(), then a thread starts to cater for those timed events. Similarly, if the Java subsystem starts up, that requires a thread as well.

Such a large array of processes might seem like an overhead, but it isn't. Firstly, all the non-script processes run from the same binary program. Under Linux, large portions of those binaries are shared between like processes: the code part; parts of any shared libraries; even some of the data is shared.

You can confirm this with the "lsof" command. It is used to sticky-beak inside a running process to see what files are being used. A convenient syntax which picks up all the processes starting with "moz" is:

lsof -c moz > /tmp/mytemp

Examine the dumped "mytemp" file and you'll see that all the Mozilla processes have the same sets of files open. They're identical in structure, but not in action -- each one performs a different task.

Fortunately, this multi-thread complexity is well-hidden by the platform. At the application level, Mozilla provides a single, unified interface to the programmer or user.


Nigel McFarlane is an open source software analyst and technologist. He has an extensive programming background and degrees in computer science and physics. His latest book is Rapid Application Development with Mozilla from Prentice Hall PTR. Nigel also answers questions as the resident Web and software development expert on SearchEnterpriseLinux.com.

Rate this Tip
To rate tips, you must be a member of SearchEnterpriseLinux.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Enterprise Linux Web Server & Application Server
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts