I came up with what I think is a good idea for making multithreading
programming easier in any .NET language. I dont know where else to post it,
so I'll try here.
..NET 2.0 adds the capability to write anonymous functions, it would be nice
if there was a "parallel" statement, that could simplify writing threadprocs.
e.g. (theoretical c#)
public void DoSomeParallelStuff() {
parallel
{
{
// do some network stuff
// this is an anonymous ThreadProc
}
{
// do some IO stuff
}
{
// do some DB stuff
}
}
// do other stuff, on caller thread
}
behind the scenes the compiler could create the anonymous functions, add
them to the ThreadPool by calling ThreadPool.QueueUserWorkItem. in some cases
it would be nice to automatically block the caller thread, maybe a sister
statement "parallel-blocked"
parrallel-blocked {
{
// read from drive c:
StreamReader rd = new StreamReader("C:\test.txt");
...
}
{
// read from drive d: (done in parallel)
StreamReader rd = new StreamReader("D:\test.txt");
...
}
}
// thread blocks until all parallel anonymous functions complete
Console.WriteLine("Tasks complete");
I think this would make it much easier to write multithreaded code. I've
actually added this feature to a compiler I'm working on and it works quite
nicely. 10 2243
Add the 'YouKnowWhatIMean' and 'HereAMiracleOccurs' while your'e at it.
"Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com... I came up with what I think is a good idea for making multithreading programming easier in any .NET language. I dont know where else to post it, so I'll try here.
.NET 2.0 adds the capability to write anonymous functions, it would be nice if there was a "parallel" statement, that could simplify writing threadprocs. e.g. (theoretical c#)
public void DoSomeParallelStuff() { parallel { { // do some network stuff // this is an anonymous ThreadProc } { // do some IO stuff } { // do some DB stuff } }
// do other stuff, on caller thread }
behind the scenes the compiler could create the anonymous functions, add them to the ThreadPool by calling ThreadPool.QueueUserWorkItem. in some cases it would be nice to automatically block the caller thread, maybe a sister statement "parallel-blocked"
parrallel-blocked { { // read from drive c: StreamReader rd = new StreamReader("C:\test.txt"); ... } { // read from drive d: (done in parallel) StreamReader rd = new StreamReader("D:\test.txt"); ... } }
// thread blocks until all parallel anonymous functions complete Console.WriteLine("Tasks complete");
I think this would make it much easier to write multithreaded code. I've actually added this feature to a compiler I'm working on and it works quite nicely.
Not quite what you asked for but, if you go to http://research.microsoft.com/resear...s/default.aspx and download
the bits for
"C# Software Transactional Memory" you will find some help for creating
parallel threaded systems.
MSR is very cool.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com... I came up with what I think is a good idea for making multithreading programming easier in any .NET language. I dont know where else to post it, so I'll try here.
.NET 2.0 adds the capability to write anonymous functions, it would be nice if there was a "parallel" statement, that could simplify writing threadprocs. e.g. (theoretical c#)
public void DoSomeParallelStuff() { parallel { { // do some network stuff // this is an anonymous ThreadProc } { // do some IO stuff } { // do some DB stuff } }
// do other stuff, on caller thread }
behind the scenes the compiler could create the anonymous functions, add them to the ThreadPool by calling ThreadPool.QueueUserWorkItem. in some cases it would be nice to automatically block the caller thread, maybe a sister statement "parallel-blocked"
parrallel-blocked { { // read from drive c: StreamReader rd = new StreamReader("C:\test.txt"); ... } { // read from drive d: (done in parallel) StreamReader rd = new StreamReader("D:\test.txt"); ... } }
// thread blocks until all parallel anonymous functions complete Console.WriteLine("Tasks complete");
I think this would make it much easier to write multithreaded code. I've actually added this feature to a compiler I'm working on and it works quite nicely.
<=?Utf-8?B?Sm9zaHVhIE51c3NiYXVt?= <Joshua Nu******@discussions.microsoft.com>> wrote:
<snip> I think this would make it much easier to write multithreaded code. I've actually added this feature to a compiler I'm working on and it works quite nicely.
I don't know - I can't think of many situations where I've used
multithreading where it would be more readable than doing things more
explicitly.
I prefer the language to remain nice and small, not having much stuff
which is threading-specific. (Even "lock" would have been better to use
the "using" pattern, IMO.)
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... <=?Utf-8?B?Sm9zaHVhIE51c3NiYXVt?= <Joshua Nu******@discussions.microsoft.com>> wrote:
<snip>
I think this would make it much easier to write multithreaded code. I've actually added this feature to a compiler I'm working on and it works quite nicely. I don't know - I can't think of many situations where I've used multithreading where it would be more readable than doing things more explicitly.
I prefer the language to remain nice and small, not having much stuff which is threading-specific. (Even "lock" would have been better to use the "using" pattern, IMO.)
While I tend to agree, I do see some value in allowing easy parallelization
of loops or over enumerations. However it certainly can be converted to an
API.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
"Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com... I came up with what I think is a good idea for making multithreading programming easier in any .NET language. I dont know where else to post it, so I'll try here.
.NET 2.0 adds the capability to write anonymous functions, it would be nice if there was a "parallel" statement, that could simplify writing threadprocs. e.g. (theoretical c#)
<snip examples>
What I have to ask is why would a compiler option be best here? Could you
not use 2.0 anonymous method and a simple api:
Parallel.NonBlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)
or
Parallel.BlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)
// thread blocks until all parallel anonymous functions complete
Console.WriteLine("Tasks complete");
I do see value in parallelization in the language(or a subset of it anyhow),
but not in this particular form. Permitting the runtime or language to
parallelize long running loops in a form that OpenMP permits would be
interesting, for example.
On other news, Its nice to see someone else working on a compiler. Are you
starting from scratch or basing off mono's?
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... <=?Utf-8?B?Sm9zaHVhIE51c3NiYXVt?= <Joshua Nu******@discussions.microsoft.com>> wrote:
<snip>
I think this would make it much easier to write multithreaded code. I've actually added this feature to a compiler I'm working on and it works quite nicely. I don't know - I can't think of many situations where I've used multithreading where it would be more readable than doing things more explicitly.
I prefer the language to remain nice and small, not having much stuff which is threading-specific. (Even "lock" would have been better to use the "using" pattern, IMO.)
While I tend to agree, I do see some value in allowing easy parallelization
of loops or over enumerations. However it certainly can be converted to an
API.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
"Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com... I came up with what I think is a good idea for making multithreading programming easier in any .NET language. I dont know where else to post it, so I'll try here.
.NET 2.0 adds the capability to write anonymous functions, it would be nice if there was a "parallel" statement, that could simplify writing threadprocs. e.g. (theoretical c#)
<snip examples>
What I have to ask is why would a compiler option be best here? Could you
not use 2.0 anonymous method and a simple api:
Parallel.NonBlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)
or
Parallel.BlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)
// thread blocks until all parallel anonymous functions complete
Console.WriteLine("Tasks complete");
I do see value in parallelization in the language(or a subset of it anyhow),
but not in this particular form. Permitting the runtime or language to
parallelize long running loops in a form that OpenMP permits would be
interesting, for example.
On other news, Its nice to see someone else working on a compiler. Are you
starting from scratch or basing off mono's?
Thanks, that was helpful.
I actually started my compiler from scratch. its basically an XML syntax
for writing .NET programs. e.g.
<method name="Foo">
<parameters>
<parameter type="int" name="arg1"/>
</parameters>
<statements>
<if condition="arg1 == 22">
<statements>
<declare type="SomeClass" variable="obj" initializer="NEW SomeClass()"/>
<call expression="obj.CallMe()"/>
</statements>
</if>
</statements>
</method>
Because i'm using XML and I have an XML schema, half of the code validation
is done out of the box. So I beleive the mono compiler is overkill for this
project. (though my compiler should be able to run on the mono clr)
The idea isnt to hand code applications in XML, that would be very tedious.
So I'm also working on an IDE for writing code completely visually.
Avalon and 3D interfaces are coming, and I think it can help IDE technology
too.
"Daniel O'Connell [C# MVP]" wrote: "Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in message news:2B**********************************@microsof t.com...I came up with what I think is a good idea for making multithreading programming easier in any .NET language. I dont know where else to post it, so I'll try here.
.NET 2.0 adds the capability to write anonymous functions, it would be nice if there was a "parallel" statement, that could simplify writing threadprocs. e.g. (theoretical c#) <snip examples>
What I have to ask is why would a compiler option be best here? Could you not use 2.0 anonymous method and a simple api:
Parallel.NonBlockingExecute( delegate { //do IO }, delegate {//do DB }, delegate {//do network }, )
or Parallel.BlockingExecute( delegate { //do IO }, delegate {//do DB }, delegate {//do network }, )
// thread blocks until all parallel anonymous functions complete Console.WriteLine("Tasks complete");
I do see value in parallelization in the language(or a subset of it anyhow), but not in this particular form. Permitting the runtime or language to parallelize long running loops in a form that OpenMP permits would be interesting, for example.
On other news, Its nice to see someone else working on a compiler. Are you starting from scratch or basing off mono's?
Thanks, that was helpful.
I actually started my compiler from scratch. its basically an XML syntax
for writing .NET programs. e.g.
<method name="Foo">
<parameters>
<parameter type="int" name="arg1"/>
</parameters>
<statements>
<if condition="arg1 == 22">
<statements>
<declare type="SomeClass" variable="obj" initializer="NEW SomeClass()"/>
<call expression="obj.CallMe()"/>
</statements>
</if>
</statements>
</method>
Because i'm using XML and I have an XML schema, half of the code validation
is done out of the box. So I beleive the mono compiler is overkill for this
project. (though my compiler should be able to run on the mono clr)
The idea isnt to hand code applications in XML, that would be very tedious.
So I'm also working on an IDE for writing code completely visually.
Avalon and 3D interfaces are coming, and I think it can help IDE technology
too.
"Daniel O'Connell [C# MVP]" wrote: "Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in message news:2B**********************************@microsof t.com...I came up with what I think is a good idea for making multithreading programming easier in any .NET language. I dont know where else to post it, so I'll try here.
.NET 2.0 adds the capability to write anonymous functions, it would be nice if there was a "parallel" statement, that could simplify writing threadprocs. e.g. (theoretical c#) <snip examples>
What I have to ask is why would a compiler option be best here? Could you not use 2.0 anonymous method and a simple api:
Parallel.NonBlockingExecute( delegate { //do IO }, delegate {//do DB }, delegate {//do network }, )
or Parallel.BlockingExecute( delegate { //do IO }, delegate {//do DB }, delegate {//do network }, )
// thread blocks until all parallel anonymous functions complete Console.WriteLine("Tasks complete");
I do see value in parallelization in the language(or a subset of it anyhow), but not in this particular form. Permitting the runtime or language to parallelize long running loops in a form that OpenMP permits would be interesting, for example.
On other news, Its nice to see someone else working on a compiler. Are you starting from scratch or basing off mono's?
"Josh Nussbaum" <Josh Nu******@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com... Thanks, that was helpful.
I actually started my compiler from scratch. its basically an XML syntax for writing .NET programs. e.g.
<method name="Foo"> <parameters> <parameter type="int" name="arg1"/> </parameters> <statements> <if condition="arg1 == 22"> <statements> <declare type="SomeClass" variable="obj" initializer="NEW SomeClass()"/> <call expression="obj.CallMe()"/> </statements> </if> </statements> </method>
Because i'm using XML and I have an XML schema, half of the code validation is done out of the box. So I beleive the mono compiler is overkill for this project. (though my compiler should be able to run on the mono clr)
Ahh, I see. I thought you meant a C# compiler, ;).
Interesting idea, good luck on it. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Yuancai \(Charlie\) Ye |
last post by:
Hi, All:
I am happy to annouce that we have formally released our latest SocketPro
version 4 at www.udaparts.com, an advanced remoting framework written from
batching/queue, asynchrony and...
|
by: bpontius |
last post by:
The GES Algorithm
A Surprisingly Simple Algorithm for Parallel Pattern Matching
"Partially because the best algorithms presented in the literature
are difficult to understand and to implement,...
|
by: paytam |
last post by:
Hi all,
Is it possible to write parallel programming in C?
I mean for example a simple program like I have a clock on a program
that show me current time and and at the same time another job like...
|
by: ramyach |
last post by:
Hi friends,
I need to write a parallel code in 'C' on the server that is
running SGI Irix 6.5. This server supports MIPS Pro C compiler. I don't
have any idea of parallel C languages. I looked...
|
by: Joshua Nussbaum |
last post by:
I came up with what I think is a good idea for making multithreading
programming easier in any .NET language. I dont know where else to post it,
so I'll try here.
..NET 2.0 adds the capability...
|
by: fiepye |
last post by:
Hello.
I am interested in parallel computing in Python. Except other modulesI would like to use new modules for vector and matrix operations and scientific computing SciPy and NumPy. I have...
|
by: Prime Mover |
last post by:
Hello all,
I have got the pseudo-code below that I would like to convert to c
language. The algorithm calculates Pi value. I am somewhat familiar
with C language, but I am just starting to learn...
|
by: John |
last post by:
I have a program that needs to run on a regular basis that looks at a
queue table in my database. If there are items in the queue database
I need to grab the data from the database and pass it to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |