This article applies to macOS only.
- Turbo Pascal Free Download
- Download Free Pascal 64 Bit
- Free Pascal Machine Learning
- Free Pascal For Mac
See also: Multiplatform Programming Guide
Turbo Pascal Free Download
The objective here is to build PPC and possibly 68K compilers, first as cross-compilers to run on a PC and then to run natively on Mac OS 9. Part of the incentive for this is to investigate whether a PPC Mac, e.g. My (MarkMLl) G3 beige with 'Old World' ROMs, is a usable testbed for the fixed 68K compiler which Sven has added to trunk at around 2.8.
│English (en) │
- 1Overview
- 2Managing App Nap
- 3NSActivityOptions
- 5App Nap status
- 6Enhancing App Nap
- 6.1Implement active application transition delegate methods
- 6.2Register for application-level occlusion notifications
Overview
macOS 10.9 (Mavericks) introduced substantial power-saving features under the App Nap umbrella, especially for laptops. App Nap is based on several key principles:
- The features work without the developer needing to modify existing applications.
- The features keep the hardware as idle as possible given the demand for resources.
- When a Mac is on battery power, only the work the user requests or that is absolutely essential is done.
- Newer Pascal compilers exist which are widely used. Pascal was the primary high-level language used for development in the Apple Lisa, and in the early years of the Mac. Parts of the original Macintosh operating system were hand-translated into Motorola 68000 assembly language from the Pascal sources.
- I like Free Pascal the most, for beginning I believe it is the best because you don't have too much fancy GUI features to distract you from programming for beginners (algorithms, procedural thinking.). I didn't try to run this on Mac but it should work. I have used Free Pascal on Linux and Windows with satisfaction.
App Nap is activated by the operating system when:
- The application's windows are not visible; eg minimised to the dock or hidden by another application's window(s).
- The application has not updated any visible part of an open window for some time.
- The application is not playing audio.
- The application is not using OpenGL graphics.
- The application is in the background.
- The application has not informed macOS that it is still active via IOKit power management or NSProcessInfo assertions.
The App Nap power-saving measures include:
- Timer throttling: The frequency with which an application's timers are executed is reduced, increasing CPU idle time when running applications that, for example, check for data.
- I/O throttling: Disk and network activity is assigned the lowest priority for applications that are 'napping' thereby reducing the speed at which the application can read/write data from/to a device. This also reduces the likelihood that a napping application will impact an application which is actively being used.
- Priority reduction: The UNIX process priority of an application is reduced so that it receives less available CPU time.
Download Free Pascal 64 Bit
Timer coalescing
Timer coalescing, although not an App Nap feature, was introduced in Mavericks at the same time. To maximise the amount of time that the CPU spends at idle, timer coalescing shifts the execution of timers by a small amount so that timers of multiple applications are executed at the same time. This is done by applying a time window to every timer based on the importance of the process. A timer can be executed at any time during this window, so may be shifted backward or forward a small amount so that it lines up with other timers that need to be executed at similar times. The timer windows are:
Process type | Timer window |
---|---|
Application (default) | 1ms |
System daemon | 70-90ms |
Background process | 80-120ms |
Critical/Real time process | 0ms |
The NSTimer class in Mavericks introduced a new tolerance parameter which enables developers to tune how timely timer-event driven events need to be.
Managing App Nap
App Nap introduced a new API in NSProcessInfo which gives developers the ability to inform the operating system when an application is performing a long-running operation that may need to prevent App Nap or system sleep.
Be aware that failing to execute endActivity after a beginActivityWithOptions for an extended period of time can have significant negative impacts on the performance of your user's computer, so only use the minimum amount of time required.
Automatic termination
Automatic termination is a feature introduced in macOS 10.7 (Lion) that you must explicitly code for in your application. If it is enabled, then your application needs to save the current state of its user interface so that it can be restored later . The system can kill the underlying process for an auto-terminable application at any time, so saving this information maintains application continuity. The system usually kills an application’s underlying process some time after the user has closed all of its windows. However, the system may also kill an application with open windows if it is not currently visible on the screen.
To support automatic termination, you need to:
- Declare support for automatic termination either programmatically or setting the NSSupportsAutomaticTermination key value to YES in the application's Info.plist file.
- Support saving and restoring the application's window configurations.
- Save the user’s data at appropriate times.
- Single-window, library-style applications should implement strategies for saving data at appropriate checkpoints.
- Multiwindow, document-based applications can use the autosaving and saveless documents capabilities in NSDocument.
You can also use the App Nap API to control automatic termination.
is equivalent to:
NSActivityOptions
Option | Effect |
---|---|
NSActivityIdleDisplaySleepDisabled | require the screen to stay powered on |
NSActivityIdleSystemSleepDisabled | prevent idle sleep |
NSActivitySuddenTerminationDisabled | prevent sudden termination |
NSActivityAutomaticTerminationDisabled | prevent automatic termination |
NSActivityUserInitiated | indicate the application is performing a user-requested action |
NSActivityUserInitiatedAllowingIdleSystemSleep | indicate the application is performing a user-requested action, but that the system can sleep on idle |
NSActivityBackground | indicate the application has initiated some kind of work, but not as the direct result of user request |
NSActivityLatencyCritical | indicate the activity requires the highest amount of timer and I/O precision available |
Free Pascal Machine Learning
Recommended usage
NSActivityUserInitiated: Used for finite length activities that the user has explicitly started. Examples include exporting or downloading a user specified file.
NSActivityBackground: Used for finite length activities that are part of the normal operation of your application but are not explicitly started by the user. Examples include autosaving, indexing, and automatic downloading of files.
NSActivityLatencyCritical: If your application requires high priority I/O, you can include the flag (using a bitwise OR). You should only use this flag for activities like audio or video recording that really do require high priority.
Example code
App Nap status
Free Pascal For Mac
There are two ways of checking the App Nap status of your application.
Method 1: Activity Monitor
Open Applications > Utilities > Activity Monitor which shows the status of App Nap for all running applications as well as other useful information like the energy impact of each application on the system:
Method 2: pmset
Open an Applications > Utilities > Terminal and type the command:
which will produce the following output when you run the example code above and click the BeginActivity and EndActivity buttons.
Enhancing App Nap
While App Nap operates automatically, with very little effort you can enhance its capabilities by actively reducing your application's energy footprint and further lengthening the time users can use their battery-powered devices without needing to plug them into the power.
Your application knows best about the importance of its activity and should not rely on App Nap to put it into an idle state. The most effective way to enhance App Nap is for your application to listen for notifications that it’s no longer in active use and to reduce or suspend energy-intensive work as quickly as possible which can happen well before the system triggers App Nap automatically.
Implement active application transition delegate methods
Implement NSApplicationDelegate methods in your application delegate to receive calls when the active state of your application — whether it’s in the foreground or not — changes.
Method | When sent by the default notification center | Significance |
---|---|---|
applicationWillResignActive | Immediately before the application is deactivated and no longer the foreground (frontmost) application. | Start winding down activity that can be stopped entirely once the change in state has completed. |
applicationDidResignActive | Immediately after the application is deactivated and gives up its position as the foreground application. | Stop any power-intensive operations, animations, and UI updates as much as possible. |
applicationWillBecomeActive | Immediately before the application becomes active and comes to the front. | Start resuming operations. |
applicationDidBecomeActive | Immediately after the application becomes active. | Fully resume operations that were reduced or halted. |
Example code
In the example code below the relevant delegate methods simply log their occurrence. In a real application you would need to replace them with the desired behaviours to reduce or suspend relevant activities and restart activities as required.
Typical log output when the executable is started from an Applications > Utilities > Terminal:
Alternatively, you can view the output using the Applications > Utilities > Console.
Register for application-level occlusion notifications
As soon as your application or any of its windows becomes hidden, your application should immediately halt any work that is no longer useful. When it becomes visible again, it can immediately refresh its content and resume any power-intensive operations.
Your application is considered hidden from the user when:
- Windows of other applications occlude the windows of your application.
- The screen saver is on and occluding all applications’ windows.
- Your application is in a Mission Control space where the user is not working.
applicationDidChangeOcclusionState tells the delegate that the application’s occlusion state changed.
On receiving this notification, you can query the application's occlusion state. Note that this only notifies about changes in the state of the occlusion, not when the occlusion region changes. You can use this notification to increase responsiveness and save power by halting any expensive calculations that the user cannot see.
If the NSApplicationOcclusionStateVisible global constant variable is set, it means that at least part of a window owned by your application is visible, so your application should continue working as normal. If the variable is not set, it means that no part of any window owned by your application is visible and your application should reduce or halt its operations and calculations because the user will not be able to see the results.
Example code
In the example code below the relevant delegate method simply logs its occurrence. In a real application you would need to replace it with the desired behaviour to reduce or suspend relevant activities and restart activities as required.
Typical log output when the executable is started from an Applications > Utilities > Terminal:
Alternatively, you can view the output using the Applications > Utilities > Console.
See also
- NSProcessInfo - accessing system information.
External Links
- Apple: Energy Efficiency Guide for Mac Apps.
- Apple: NSActivityOptions.
- Apple: NSProcessInfo.
- Apple: NSApplicationDelegate.
- Apple: NSApplicationDidChangeOcclusionStateNotification.
- Apple: NSTimer.
Overview
Free Pascal is a mature, versatile, open source Pascal compiler. It can target many processor architectures: Intel x86 (16 and 32 bit), AMD64/x86-64, PowerPC, PowerPC64, SPARC, SPARC64, ARM, AArch64, MIPS, Motorola 68k, AVR, and the JVM. Supported operating systems include Windows (16/32/64 bit, CE, and native NT), Linux, Mac OS X/iOS/iPhoneSimulator/Darwin, FreeBSD and other BSD flavors, DOS (16 bit, or 32 bit DPMI), OS/2, AIX, Android, Haiku, Nintendo GBA/DS/Wii, AmigaOS, MorphOS, AROS, Atari TOS, and various embedded platforms. Additionally, support for RISC-V (32/64), Xtensa, and Z80 architectures, and for the LLVM compiler infrastructure is available in the development version. Additionally, the Free Pascal team maintains a transpiler for pascal to Javascript called pas2js.
Latest News
- FPC has moved to Gitlab!
All SVN repositories have been converted to git and moved to gitlab. The Mantis bugtracker has also been converted to gitlab.
You can find instructions in the Development page or in the Wiki.
Bugs can be reported here.
- FPC version 3.2.2 has been released!
This version is a point update to 3.2.0 and contains bugfixes and updated packages, some of which are high priority. In this case a new target was also backported from trunk.
There is a list of changes that may break backward compatibility. You can also have a look at the FPC 3.2.2 documentation.
Downloads are available at the download section. Some links might be stale but will be updated in the coming days. If you have trouble using FTP due to recent browser updates, try the sourceforge mirror.
- FPC version 3.2.0 has been released!
This version is a major new release and contains bugfixes and updates packages, new features and new targets. Due to the age of the FPC 3.0 branch (5 years!) it is recommended to upgrade as soon as possible.
There is a list of changes that may break backward compatibility. You can also have a look at the FPC 3.2.0 documentation.
Downloads are available at the download section. Some links might be stale but will be updated in the coming days.
- FPC has gained several new features lately in trunk (which will not be in the upcoming FPC 3.2.0 release):
- Multiple helper types can now be active at the same time
- Support has been added for custom attributes
- The compiler can now generate LLVM bitcode for select platforms (Darwin/x86-64, Linux/x86-64, Linux/AArch64, Linux/ARMHF)
While FPC 3.2.0 will not have support for the above list, it will have its own collection of new features and fixes!
Today FPC celebrates its 25th birthday !
25 years have passed since 8 june 1993, and FPC still does not only exists, but is more alive and kicking than ever!
As required by the European GDPR, we have published a privacy statement
Current Version
Version 3.2.2 is the latest stable version of Free Pascal. Hit the download link and select a mirror close to you to download your copy. The development releases have version numbers 3.3.x. See the development page how to obtain the latest sources and support development.
Features
The language syntax has excellent compatibility with TP 7.0 as well as with most versions of Delphi (classes, rtti, exceptions, ansistrings, widestrings, interfaces). A Mac Pascal mode, largely compatible with Think Pascal and MetroWerks Pascal, is also available. Furthermore Free Pascal supports function overloading, operator overloading, global properties and several other extra features.
Requirements
x86 architecture:For the 80x86 version at least a 386 processor is required, but a 486 is recommended. The Mac OS X version requires Mac OS X 10.4 or later, with the developer tools installed.PowerPC architecture:
Any PowerPC processor will do. 16 MB of RAM is required. The Mac OS classic version is expected to work System 7.5.3 and later. The Mac OS X version requires Mac OS X 10.3 or later (can compile for 10.2.8 or later), with the developer tools installed. On other operating systems Free Pascal runs on any system that can run the operating system.ARM architecture
16 MB of RAM is required. Runs on any ARM Linux installation.Sparc architecture
16 MB of RAM is required. Runs on any Sparc Linux installation (solaris is experimental).
License
The packages and runtime library come under a modified Library GNU Public License to allow the use of static libraries when creating applications. The compiler source itself comes under the GNU General Public License. The sources for both the compiler and runtime library are available; the complete compiler is written in Pascal.