This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This article includes a list of references, related reading, or external links, but its sources remain unclear because it lacks inline citations. Please help to improve this article by introducing more precise citations. (September 2023) (Learn how and when to remove this template message) This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.Find sources: "Netscape Portable Runtime" – news · newspapers · books · scholar · JSTOR (September 2023) This article's tone or style may not reflect the encyclopedic tone used on Wikipedia. See Wikipedia's guide to writing better articles for suggestions. (September 2023) (Learn how and when to remove this template message) (Learn how and when to remove this template message)
Netscape Portable Runtime
Developer(s)Mozilla Foundation / Mozilla Corporation
Stable release
4.35[1] Edit this on Wikidata / 12 September 2022; 16 months ago (12 September 2022)
Repository
Written inC
Operating systemCross-platform
TypeSoftware library
LicenseMPL
Websitefirefox-source-docs.mozilla.org/nspr/index.html

The Netscape Portable Runtime, or NSPR, is a cross-platform abstraction layer library for the C programming language. It provides a uniform API for various operating system functions.

History

Much of the library, and perhaps the overall thrust of it in the Gromit environment, provides the underpinnings of the Java virtual machine, more or less mapping the sys layer that Sun defines for the porting of the Java VM to various platforms. NSPR does go beyond that requirement in some areas, as it also functions as the platform-independent layer for most of the servers produced by Netscape.

The first generation of NSPR originally aimed just to satisfy the requirements of porting Java to various host environments. NSPR20, an effort started in 1996, built on that original idea, though very little remains of the original code. (The "20" in "NSPR20" does not mean "version 2.0" but rather "second generation".) Many of the concepts show reform, expansion, and maturation. In 2009, NSPR still functioned appropriately as the platform-dependent layer under Java, but it also served in supporting clients written entirely in C or in C++.

Features

Threads

Threads feature prominently in NSPR. The software industry's offering of threads lacks consistency. NSPR, while far from perfect, does provide a single API to which clients may program and expect reasonably consistent behavior. The operating systems provide everything from no concept of threading at all up to and including sophisticated, scalable and efficient implementations. NSPR makes as much use of what the systems offer as it can. NSPR aims to impose as little overhead as possible in accessing those appropriate system features.

Thread synchronization

Thread synchronization loosely depends on monitors as described by C. A. R. Hoare in "Monitors: An operating system structuring concept", Communications of the ACM, 17(10), October 1974 and then formalized by Xerox' Mesa programming language ("Mesa Language Manual", J.G. Mitchell et al., Xerox PARC, CSL-79-3 (Apr 1979)). This mechanism provides the basic mutual exclusion (mutex) and thread notification facilities (condition variables) implemented by NSPR. Additionally, NSPR provides synchronization methods more suited for use by Java. The Java-like facilities include monitor reentrancy, implicit and tightly bound notification capabilities with the ability to associate the synchronization objects dynamically.

I/O

NSPR's I/O slightly augments the Berkeley sockets model and allows arbitrary layering. The designers originally intended to export synchronous I/O methods only, relying on threads to provide the concurrency needed for complex applications. That method of operation remains preferred, though one can configure the network I/O channels as non-blocking in the traditional sense.

Network addresses

Part of NSPR deals with manipulation of network addresses. NSPR defines an IP-centric network address object. While it does not define the object as opaque, the API provides methods that allow and encourage clients to treat the addresses as polymorphic items. In this area NSPR aims to provide a migration path between IPv4 and IPv6. To that end one can perform translations of ASCII strings (DNS names) into NSPR's network address structures, regardless of whether the addressing technology uses IPv4 or IPv6.

Time

NSPR makes timing facilities available in two forms: interval timing and calendar functions.

Interval timers are based on a free running, 32-bit, platform-dependent resolution timer. Such timers are normally used to specify timeouts on I/O, waiting on condition variables and other rudimentary thread scheduling. Since these timers have finite namespace and are free running, they can wrap at any time. NSPR does not provide an epoch, but expects clients to deal with that issue. The granularity of the timers is guaranteed to be between 10 microseconds and 1 millisecond. This allows a minimal timer period in of approximately 12 hours. But in order to deal with the wrap-around issue, only half that namespace may be used. Therefore, the minimal usable interval available from the timers is slightly less than six hours.

Calendar times are 64-bit signed numbers with units of microseconds. The epoch for calendar times is midnight, January 1, 1970, Greenwich Mean Time. Negative times extend to times before 1970, and positive numbers forward. Use of 64 bits allows a representation of times approximately in the range of −30000 to the year 30000. There exits a structural representation (i.e., exploded view), routines to acquire the current time from the host system, and convert them to and from the 64-bit and structural representation. Additionally there are routines to convert to and from most well-known forms of ASCII into the 64-bit NSPR representation.

Memory management

NSPR provides API to perform the basic malloc, calloc, realloc and free functions. Depending on the platform, the functions may be implemented almost entirely in the NSPR runtime or simply shims that call immediately into the host operating system's offerings.

Linking

Support for linking (shared library loading and unloading) forms part of NSPR's feature set. In most cases this is simply a smoothing over of the facilities offered by the various platform providers.

See also

Sources

 This article incorporates text from a free content work. Licensed under CC BY-SA 2.5 (license statement/permission). Text taken from About NSPR​, Larry H., Mozilla.

References

  1. ^ "NSPR 4.35 Release". 12 September 2022. Retrieved 30 August 2023.