From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e81fd3a32a1cacd2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 05 Mar 2007 23:33:31 -0600 From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Does Ada tasking profit from multi-core cpus? References: X-Newsreader: Tom's custom newsreader Message-ID: Date: Mon, 05 Mar 2007 23:33:31 -0600 NNTP-Posting-Host: 67.164.83.70 X-Trace: sv3-TGXDfmxkaazVfb44cD/cnZc/ITqTXNCi5ATosI/bt6R1R8yKxjb2SNQPcG7io6mul3WvvNI1kUCUeJ2!DBPQfYzc++6RKiEiLIHHovimSJOAj229/+1aG8n5N/cluZvXxu9A16NxH8brDZTctFLQTKvfNcDa!AGG9gir/isV6tg== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.34 Xref: g2news2.google.com comp.lang.ada:9706 Date: 2007-03-05T23:33:31-06:00 List-Id: > 1. Whether protected object's functions are indeed executed concurrently > when come from the tasks running on different cores? A quick test with a single protected object containing a single, long-duration, function appears to have just one call of the function active at a time, even if the function is called from two different tasks. global_flag : integer := 0; protected body pt is function f(id : integer) return natural is change_count : natural := 0; begin global_flag := id; for i in 1 .. 10_000_000 loop if global_flag /= id then change_count := change_count; global_flag := id; end if; end loop; return change_count; end f; end pt; One task calls pt.f(id=>1) and the other calls pt.f(id=>2). They both get a result of zero back from their function call. This was with Gnat 3.15p Windows 2000 on a dual core Pentium. If I change it from a single protected object to two instances of a protected type, then the function calls are overlapped and return non-zero results. > 3. Can a task switch cores? If yes, what is the overhead of switching? By "switch cores" do you mean that the particular hardware stack pointers swap which stack they are pointing to? I think this is an OS question and, for Windows, I don't know how one asks "which core am I currently running on" - or indeed if that questions makes any sense.