Created
September 9, 2020 12:16
-
-
Save kvakvs/f62dfaaeace0d5c4aee4de872fea20b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%------------------------------------------------------------------- | |
%%% @copyright (C) 2020, Erlang Solutions Ltd. | |
%%% @doc Create a long running process which consumes CPU periodically | |
%%% @end | |
%%%------------------------------------------------------------------- | |
-module(problem_cpu). | |
%% API | |
-export([start/0]). | |
start() -> | |
erlang:spawn(fun process_loop/0). | |
process_loop() -> | |
% 1 million empty cycles | |
counter(1000000), | |
% Sleep a little | |
receive after 250 -> ok end, | |
% More work? | |
process_loop(). | |
counter(0) -> ok; | |
counter(N) -> counter(N - 1). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment